Slack-App-Watson:Watson 失去了先前收到的消息的意图

Slack-App-Watson: Watson looses intent from previous message received

我正在编写一个简单的 Slack 机器人,它可以查找给定位置的天气状况。

在 Watson 对话聊天框中,Watson 做得很好:

  • me: Weather please
  • Watson (detected #weather_asked): Where do you want to know the weather conditions?
  • me: Paris
  • Watson (detected @location for intent #weather_asked): Finding weather conditions for Paris...

但在我的 node.js 应用程序(连接到 Slack)中,Watson 似乎“没有记住我正在为 #weather_asked 意图提供位置":

  • me: Weather please
  • Watson (detected #weather_asked): Where [...]?
  • me: Paris
  • Watson (detected only @location and intent #location_given): I am sorry, I did not understand. (fallback anything_else)

就像 Watson,当通过我的 NodeJS 应用程序使用时,它忘记了最初的意图 #weather_asked 并且 "reset" 到它的主要对话框。我错过了什么?

我的 Watson Conversation Dialogs 配置的屏幕截图:http://imgur.com/a/vKo8P

编辑: 我发现我的应用程序使用新的对话 ID 将用户的输入发送到 Watson。如果它已经存在,我将尝试设置它。

我找到了解决办法!问题是我没有告诉 Watson 我的用户已经开始与他对话(它?)。

我制作了一段简单的代码,用于存储按 Slack 的 user_id 分组的现有上下文。如果这个 user_id 的上下文已经存在,那么我的应用程序将调用 Watson API 并将这个上下文附加到请求中,这样 Watson 就知道这个新用户的输入跟在前一个用户的输入之后。