我最近从 DialogFlowV1
更新到 DialogFlowV2
。
我发现 V2
中没有不同的 displayText
和 speech
参数。
如何从 webhook 实现发送不同的 speech
和 displayText
参数,以便我可以通过 DialogFlow
Android 客户端使用这些值。
从我从 V1 升级到 V2 的那天起,我发现 Android 的 ai.api.sdk
中 displayText
参数返回 null
这是我从网络钩子(Hook)发送的履行响应
{
"fulfillmentText": "My FulfillmentText",
"fulfillmentMessages": [
{
"text": {
"text": [
"Sample response 1",
"Sample response 2"
]
}
}
]
}
我必须对上述响应结构进行哪些更改?
最佳答案
您需要在 v2 api 的 fulfillmentText
中传递 speech
文本,并在 fulfillmentMessages
中传递 displayText
。
{
"fulfillmentText": "This will be speech.",
"fulfillmentMessages": [
{
"text": {
"text": [
"This will be text to be displayed on screen."
]
}
}
]
}
如果您没有从 Webhook 传递 fulfillmentMessages
,则 fulfillmentText
将显示在屏幕上。
响应的基本结构在 this page 上给出。 .
发送 fulfillmentText
的示例代码 (python):
import json
req = req_you_get_from_webhook_call
res = json.dumps({
'fulfillmentText': 'response from the webhook',
})
return res
关于android - 如何从 DialogFlowV2 webhook 发送不同的语音和显示文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51531185/