Dialogflow es google user.storage上的操作在同一时间通过用户的每次post呼叫清除。如何保存对话的数据?

Dialogflow es google user.storage上的操作在同一时间通过用户的每次post呼叫清除。如何保存对话的数据?,dialogflow-es,actions-on-google,Dialogflow Es,Actions On Google,我试图通过与user.storage的对话来保存数据,我访问user.storage如下: app.post('/', express.json(), (req, res) => { const agent = new WebhookClient({ request: req, response: res }) let personalD=new personalDetails(agent) function personal_details(){ personal

我试图通过与
user.storage
的对话来保存数据,我访问
user.storage
如下:

app.post('/', express.json(), (req, res) => {

  const agent = new WebhookClient({ request: req, response: res })
  let personalD=new personalDetails(agent)

  function personal_details(){
    personalD.foo()
  }

  let intentMap = new Map()
  intentMap.set('inform.PersonalDetails',personal_details) 
  agent.handleRequest(intentMap)
}


//that's the personalDetails class:

class PersonalDetails{
    constructor(agent){
        this.agent=agent;
        this.conv=this.agent.conv();
    }

    foo() {    
        this.conv.user.storage.name=this.agent.parameters.name;
        this.conv.user.storage.age=this.agent.parameters.age;
        this.conv.user.storage.gender=this.agent.parameters.gender;

        const gotname = this.conv.user.storage.name==''?0:1
        const gotage = this.conv.user.storage.age==''?0:1
        const gotgender =this.conv.user.storage.gender==''?0:1

        const name=this.conv.user.storage.name;
        const gender=this.conv.user.storage.gender;

        if (gotname && !gotage&&!gotgender) 
          this.agent.add(`Ok, ${name}, How old are you? and what is you'r gender?`)
        else if (gotname && gotage&&!gotgender) 
          this.agent.add(`Ok, ${name}, What gender you belong to`)
        else if(gotname && !gotage&&gotgender) 
          this.agent.add(`Ok, ${name}, How old are you?`)
        else if (!gotname && gotage&&gotgender) 
          this.agent.add(`What's your name please?`)
        else if (!gotname && !gotage&&gotgender) 
          this.agent.add(`Well dear ${gender}, What is your name and how old are you`)
        else if(!gotname && gotage&&!gotgender) 
          this.agent.add('Let me know what is your name and what is your gender')
        else if (!gotname && !gotage&&!gotgender) 
          this.agent.add(`I want to get to know you before we begin. what is you'r name?`)
    }
}

module.exports=PersonalDetails;
Dialogflow希望用户提供三个实体:姓名、年龄和性别。当用户没有提供所有代码时,代码会执行一些逻辑以查看缺少的内容

问题是,首先我输入姓名和年龄,然后它询问用户性别,当用户输入性别时,它已经忘记了姓名和年龄。。。
请帮助

在您的对话框Flow fulfillment code中,您正在初始化user.storage on中的参数,而不是仅当您收到用户的值时才初始化。此代码是您的问题:

this.conv.user.storage.name=this.agent.parameters.name;
this.conv.user.storage.age=this.agent.parameters.age;
this.conv.user.storage.gender=this.agent.parameters.gender;
您只需设置user.storage一次,然后就可以在任何地方直接使用它

app.intent('GetUserName', (conv, {name}) => {
  conv.user.storage.name= name; 
  conv.ask(`Hi, ${conv.user.storage.name}!.
  Please tell me how can I help you? `);
});

app.intent('AboutSC', (conv) => {
  conv.ask(`well ${conv.user.storage.name}.  What more would you like to know? `);
});

您可以直接使用
user.storage
参数。但是使用在每次请求时初始化的变量/常量将每次更改该值&没有帮助

您是否在您的Google帐户上启用了正确的用户设置?如果没有,这会阻止存储值。谢谢。是的,我已经启用了它,而且conv.user.verification也已验证,但仍然不起作用…好的,谢谢您的回复。没错,但是如果dialogflow多次输入“GetUserName”意图会怎么样?在conv.user.storage中,我初始化了更多的变量,每次都是我在当前调用中收到的变量?此外,我也尝试了您自己的方式,而不是使用:intentMap.set('inform.PersonalDetails',personal_details),并且无论我如何接收到意图调用,我都会得到以下错误:UnhandledPromiseRejectionWarning:error:WebhookClient.handlerRequest上没有处理请求的意图的处理程序在了解您想要捕获的流之后-姓名、性别、,用户的年龄。然后,应该只使用一个意图和三个参数来完成。并要求用户说出所有细节,这样只有他/她才能在对话中前进。通过这种方法,您只需输入一次带有所有参数的GetUserName。如果您使用的是dialogflow,则在对话中,将这些参数设置为必需的(必需的),以阻止用户不告知所有必需的详细信息。对于您提到的错误,请检查您的意图名称是否与代码中编写的函数名称相匹配。也请参考此链接,它是更新的解决方案关于你的第二次评论,谢谢你修复了它!第一个——在开始的时候,我确实根据需要设置了参数,但是我想使用webhook客户端来填充插槽。这个意图只是一个例子,但我在我的项目中有其他意图,用户可以回答“是”或“否”,因为我在一个意图中几乎没有必要的实体,所以我不能做任何类似于后续意图的事情,因为首先,它不会离开意图去后续,直到所有需要的实体都满了,其次,代理不会知道“是”或“否”所指的实体。你明白这个问题吗?