Parameters 在Dialogflow中使用来自不同意图的参数值

Parameters 在Dialogflow中使用来自不同意图的参数值,parameters,dialogflow-es,fulfillment,Parameters,Dialogflow Es,Fulfillment,我是Dialogflow的新手,我创建了一个机器人,可以通过不同的意图(例如名字、姓名、生日等)查询不同的用户信息。现在我正在使用一个函数来实现,我需要来自不同意图的参数值 const{姓氏、街道、房屋号、, 邮政编码,出生日期, email}=agent.parameters如果您想使用不同目的的参数值,首先必须将它们保存在webhook中。Dialogflow有一个名为的功能来帮助您完成此操作。上下文有一个参数字段,您可以在其中存储值。因此,在您的第一个意图中,您可以通过创建上下文并将值添

我是Dialogflow的新手,我创建了一个机器人,可以通过不同的意图(例如名字、姓名、生日等)查询不同的用户信息。现在我正在使用一个函数来实现,我需要来自不同意图的参数值

const{姓氏、街道、房屋号、,
邮政编码,出生日期,

email}=agent.parameters如果您想使用不同目的的参数值,首先必须将它们保存在webhook中。Dialogflow有一个名为的功能来帮助您完成此操作。上下文有一个参数字段,您可以在其中存储值。因此,在您的第一个意图中,您可以通过创建上下文并将值添加到此上下文来存储它们

第一意图

  const {last_name, street, house_no, 
     zip_code, birthdate, 
      email} = agent.parameters;

agent.context.set('context_name', 5, {'lastName' : last_name, 'street': street});
const context = agent.context.get('context_name');
const lastName = context.parameters.lastName;
const street = context.parameters.street;
在上面的示例中,5用于指示上下文的寿命。因此,这些值将在5轮对话中可用。接下来,在第二个意图中,您需要获取刚刚设置为使用这些值的上下文。之后,可以从上下文的参数字段中获取值

第二意图

  const {last_name, street, house_no, 
     zip_code, birthdate, 
      email} = agent.parameters;

agent.context.set('context_name', 5, {'lastName' : last_name, 'street': street});
const context = agent.context.get('context_name');
const lastName = context.parameters.lastName;
const street = context.parameters.street;

如果您想使用不同目的的参数值,首先必须将它们保存在webhook中。Dialogflow有一个名为的功能来帮助您完成此操作。上下文有一个参数字段,您可以在其中存储值。因此,在您的第一个意图中,您可以通过创建上下文并将值添加到此上下文来存储它们

第一意图

  const {last_name, street, house_no, 
     zip_code, birthdate, 
      email} = agent.parameters;

agent.context.set('context_name', 5, {'lastName' : last_name, 'street': street});
const context = agent.context.get('context_name');
const lastName = context.parameters.lastName;
const street = context.parameters.street;
在上面的示例中,5用于指示上下文的寿命。因此,这些值将在5轮对话中可用。接下来,在第二个意图中,您需要获取刚刚设置为使用这些值的上下文。之后,可以从上下文的参数字段中获取值

第二意图

  const {last_name, street, house_no, 
     zip_code, birthdate, 
      email} = agent.parameters;

agent.context.set('context_name', 5, {'lastName' : last_name, 'street': street});
const context = agent.context.get('context_name');
const lastName = context.parameters.lastName;
const street = context.parameters.street;