【发布时间】:2018-12-08 07:48:08
【问题描述】:
我使用 dialogflow-fulfillment 创建了一个 webhook,以根据平台正确返回不同的数据,包括我为另一个服务创建的自定义数据。我已经测试了我的 webhook,并且知道如果我将 originalDetectIntentRequest.source 更改为自定义有效负载中使用的平台,它就可以工作。
{
"payload": {
"jokes-api": {
"success": true,
"text": "These are some jokes",
}
},
"outputContexts": []
}
我可以使用dialogflow-nodejs-client-v2 的sessions.detectIntent 来获得响应,但是完整返回的平台设置为PLATFORM_UNSPECIFIED,而不是我想要的自定义有效负载。
[{
"responseId": "c56c462f-bb3b-434a-b318-3739f58e6f6d",
"queryResult": {
"fulfillmentMessages": [{
"platform": "PLATFORM_UNSPECIFIED",
"card": {
"buttons": [],
"title": "Jokes",
"subtitle": "These are some jokes",
"imageUri": ""
},
"message": "card"
}],
"queryText": "tell me a joke",
/* ... */
"intent": {
"name": "projects/my-jokes/agent/intents/56887375-3047-4993-8e14-53b20dd02697",
"displayName": "Jokes",
/* ... */
},
"intentDetectionConfidence": 0.8999999761581421,
}
}]
查看我的 webhook 的日志,我可以看到 originalDetectIntentRequest 对象存在,但未设置源。
{
"responseId": "c56c462f-bb3b-434a-b318-3739f58e6f6d",
"queryResult": {
"queryText": "tell me a joke",
"speechRecognitionConfidence": 0.9602501,
/* ... */
"intent": {
"name": "projects/my-jokes/agent/intents/56887375-3047-4993-8e14-53b20dd02697",
"displayName": "Jokes"
},
/* ... */
},
"originalDetectIntentRequest": {
"payload": {
}
},
"session": "projects/my-jokes/agent/sessions/12345"
}
如何在 dialogflow-nodejs-client-v2 中设置平台或源以获得所需的响应?
【问题讨论】:
标签: node.js google-cloud-platform dialogflow-es