Dialogflow V2 Messenger 与多条消息的集成
Dialogflow V2 Messenger Integration with Multiple Messages
我正在尝试在对 Dialogflow 的一次 Webhook 调用中发送多条消息,这些消息应传递给 Messenger。现在我的 Webhook 响应有故障 JSON 正文:
{
'fulfillmentText': "Text",
'fulfillmentMessages': [{
"platform": "facebook",
"text": [{
"text": "Text"
}]
}],
'source': "facebook"
}
当我通过 Messenger 测试 Webhook 时,我看到 is typing 符号,但从未收到 Text 消息。从 Dialogflow 控制台测试同一个 Webhook 时,我得到
Webhook execution successful
回来了。我想我缺少一些 JSON 字段来告诉 Dialogflow 它必须以哪种格式发送 JSON 两个 Messenger API。有人知道如何解决这个问题吗?
编辑:
我最近的无效试用...
{
"fulfillmentText": "Hola!",
"fulfillmentMessages": [
{
"text": {
"text": [
"Title: this is a title"
]
},
"platform": "FACEBOOK"
},
{
"text": {
"text": [
"Title: this is a title"
]
},
"platform": "FACEBOOK"
}
]
}
如果您只发送文本,则只需向 fulfillmentText
提供一个字符串,而不必提供 fulfillmentMessages
属性。
如果您确实为目标平台提供了 fulfillmentMessages
属性,Dialogflow 会将您的负载发送到 Facebook。在这种情况下,如果有效负载无效,则实际上不会在 Facebook 中显示任何消息。删除响应 JSON 的 fulfillmentMessages
属性,您的机器人应该响应。
如果您想在回复中添加一张卡片,您可以发送以下回复:
{
"fulfillmentMessages": [
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
编辑:如果你想发送多条消息,你可以通过发送这样的响应来实现(这 JSON 将发送两张相同的卡片,但你可以根据 [=16 更改消息类型(card/text/etc) =]):
{
"fulfillmentMessages": [
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
},
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
我就此问题向 Dialogflow 支持部门发送了邮件,结果发现目前无法从 webhook 发送多条消息。
Hi,
At this point, it's not possible to send sequential messages directly
from webhook. However, if you are using one of our one-click
integrations that support rich messages, you can invoke intents in
which multiple messages are defined from webhook through an event as
described at
https://dialogflow.com/docs/events#invoking_event_from_webhook.
Let me know if you have any questions.
Regards, Ankita from Dialogflow
我正在尝试在对 Dialogflow 的一次 Webhook 调用中发送多条消息,这些消息应传递给 Messenger。现在我的 Webhook 响应有故障 JSON 正文:
{
'fulfillmentText': "Text",
'fulfillmentMessages': [{
"platform": "facebook",
"text": [{
"text": "Text"
}]
}],
'source': "facebook"
}
当我通过 Messenger 测试 Webhook 时,我看到 is typing 符号,但从未收到 Text 消息。从 Dialogflow 控制台测试同一个 Webhook 时,我得到
Webhook execution successful
回来了。我想我缺少一些 JSON 字段来告诉 Dialogflow 它必须以哪种格式发送 JSON 两个 Messenger API。有人知道如何解决这个问题吗?
编辑: 我最近的无效试用...
{
"fulfillmentText": "Hola!",
"fulfillmentMessages": [
{
"text": {
"text": [
"Title: this is a title"
]
},
"platform": "FACEBOOK"
},
{
"text": {
"text": [
"Title: this is a title"
]
},
"platform": "FACEBOOK"
}
]
}
如果您只发送文本,则只需向 fulfillmentText
提供一个字符串,而不必提供 fulfillmentMessages
属性。
如果您确实为目标平台提供了 fulfillmentMessages
属性,Dialogflow 会将您的负载发送到 Facebook。在这种情况下,如果有效负载无效,则实际上不会在 Facebook 中显示任何消息。删除响应 JSON 的 fulfillmentMessages
属性,您的机器人应该响应。
如果您想在回复中添加一张卡片,您可以发送以下回复:
{
"fulfillmentMessages": [
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
编辑:如果你想发送多条消息,你可以通过发送这样的响应来实现(这 JSON 将发送两张相同的卡片,但你可以根据 [=16 更改消息类型(card/text/etc) =]):
{
"fulfillmentMessages": [
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
},
{
"platform": "FACEBOOK",
"card": {
"title": "Title: this is a title",
"subtitle": "This is an subtitle. Text can include unicode characters including emoji .",
"imageUri": "https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png",
"buttons": [
{
"text": "This is a button",
"postback": "https://assistant.google.com/"
}
]
}
}
]
}
我就此问题向 Dialogflow 支持部门发送了邮件,结果发现目前无法从 webhook 发送多条消息。
Hi,
At this point, it's not possible to send sequential messages directly from webhook. However, if you are using one of our one-click integrations that support rich messages, you can invoke intents in which multiple messages are defined from webhook through an event as described at https://dialogflow.com/docs/events#invoking_event_from_webhook.
Let me know if you have any questions.
Regards, Ankita from Dialogflow