我最近从DialogFlowV1
更新为DialogFlowV2
。
我发现displayText
中没有不同的speech
和V2
参数。
如何从webhook实现中发送不同的speech
和displayText
参数,以便我可以使用DialogFlow
Android客户端使用这些值。
从我从V1升级到V2的那一天开始,我发现displayText
参数在Android的ai.api.sdk
这是我从Webhook发送的充实响应
{
"fulfillmentText": "My FulfillmentText",
"fulfillmentMessages": [
{
"text": {
"text": [
"Sample response 1",
"Sample response 2"
]
}
}
]
}
在上述响应结构中我必须进行哪些更改?
答案 0 :(得分:2)
您需要在v2 api中的speech
中传递fulfillmentText
文本,在displayText
中传递fulfillmentMessages
。
{
"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