如何使用Dialogflow Webhook在对话中存储数据

时间:2018-09-10 16:57:22

标签: dialogflow

我正在使用dialogflow webhook,并希望在对话中存储数据。

以下是我从dialogflow docs所了解的

response.setHeader('Content-Type', 'application/json');
   response.send(JSON.stringify({
    "payload": {
        "google": {
          "expectUserResponse": true,
          "richResponse": {
            "items": [
              {
                "simpleResponse": {
                  "textToSpeech": "OKAY"
                }
              }
            ]
          }, 
          "conversationToken" : "count=1"
        }
      }
   }))

这不起作用,因为下一个请求中的JSON没有此存储的值。

1 个答案:

答案 0 :(得分:1)

您可以查看我的完整答案here。 短期使用上下文来存储参数。

使用输出上下文保存参数

{  
  "fulfillmentText":"This is a text response",
  "fulfillmentMessages":[  ],
  "source":"example.com",
  "payload":{  
    "google":{  },
    "facebook":{  },
    "slack":{  }
  },
  "outputContexts":[  
    {  
      "name":"<Context Name>",
      "lifespanCount":5,
      "parameters":{  
        "<param name>":"<param value>"
      }
    }
  ],
  "followupEventInput":{  }
}