Dialogflow V2 Facebook Messenger 通用模板示例负载
Dialogflow V2 Facebook Messenger Generic Template Example Payload
我当时使用的是 Dialogflow V1,因此决定改为使用 V2 测试版。 API 已更改,我无法恢复之前发送到 Messenger 的 Facebook 模板。
对于 V1,我使用了:
{
'speech': speech,
"data": {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}]
}
}
}
}
}
我的问题是我不知道 data
条目在 V2 中应该放在哪里。有人可以在解释 data
字段的 Dialogflow 文档中为我提供一个工作示例或 link 吗?
好的。经过几个小时的尝试,我得到了一个错误。您必须将 webhook_response 对象中的自定义 facebook 有效负载作为 fullfilment_message 数组作为 有效负载传递 像这样的对象:
{'fulfillmentMessages': [{
'payload': {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}]
}
}
}
}
}]
我当时使用的是 Dialogflow V1,因此决定改为使用 V2 测试版。 API 已更改,我无法恢复之前发送到 Messenger 的 Facebook 模板。 对于 V1,我使用了:
{
'speech': speech,
"data": {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}]
}
}
}
}
}
我的问题是我不知道 data
条目在 V2 中应该放在哪里。有人可以在解释 data
字段的 Dialogflow 文档中为我提供一个工作示例或 link 吗?
好的。经过几个小时的尝试,我得到了一个错误。您必须将 webhook_response 对象中的自定义 facebook 有效负载作为 fullfilment_message 数组作为 有效负载传递 像这样的对象:
{'fulfillmentMessages': [{
'payload': {
"facebook": {
"attachment": {
"type": "template",
"payload": {
"template_type": "button",
"text": "What do you want to do next?",
"buttons": [{
"type": "web_url",
"url": "https://www.messenger.com",
"title": "Visit Messenger"
}]
}
}
}
}
}]