gpt4 book ai didi

facebook-messenger-bot - Dialogflow V2 Messenger 与多条消息的集成

转载 作者:行者123 更新时间:2023-12-04 08:41:33 26 4
gpt4 key购买 nike

我正在尝试在对 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 将发送两张相同的卡片,但您可以根据 this documentation 更改消息类型(卡片/文本/等)):

{
"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/"
}
]
}
}
]
}

关于facebook-messenger-bot - Dialogflow V2 Messenger 与多条消息的集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47678742/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com