[英]Facebook messenger bot app - persistent menu not appearing
我正在構建一個 Facebook 聊天機器人應用程序。 我已經使用 HTTP POST 和有效的頁面訪問令牌使用一些 JSON 設置了持久菜單。
為了檢查我是否正確設置了它,我使用工作令牌向https://graph.facebook.com/v2.6/me/messenger_profile?fields=persistent_menu&access_token=TOKEN
發出 GET 請求。
我得到的回應是:
{u'data': [{u'persistent_menu': [{u'composer_input_disabled': False,
u'locale': u'en_US'},
{u'call_to_actions': [{u'call_to_actions': [{u'payload': u'whatever',
u'title': u'action1',
u'type': u'postback'},
{u'payload': u'whatever 2',
u'title': u'action2',
u'type': u'postback'}],
u'title': u'my title',
u'type': u'nested'},
{u'title': u'my title URL',
u'type': u'web_url',
u'url': u'http://google.com/',
u'webview_height_ratio': u'full'}],
u'composer_input_disabled': False,
u'locale': u'default'}]}]}
這就是我所說的,到目前為止一切都很好。
但是當我在 iOS 上打開 Messenger 應用程序或在 Chrome 桌面 Mac OS X 上訪問messenger.com
時,我沒有看到任何菜單!
奇怪的是,在我的服務器 webhook 端點上,我也確實收到了“開始使用”按鈕按下回發。 所以這是有效的。
我的 webhook 具有權限: messages, messaging_postbacks, messaging_optins, message_deliveries, message_reads
。
我試過了:
而這些都沒有奏效。 我仍然在我的 Messenger iOS 應用程序中看到一個加載微調器 - 也許 Facebook 的服務器更新我的應用程序很慢? 不過,30 分鍾似乎非常極端。
我的 JSON 用於持久菜單設置有什么問題嗎? 這似乎是唯一可能出錯的地方。
知道我做錯了什么嗎?
我回來查看,已經超過 24 小時了,仍然沒有菜單出現。
嘗試使用 Postman App 執行此操作,然后使用帶有以下參數的 POST:
https://graph.facebook.com/v2.6/me/thread_settings?access_token=xxx
並用這個填充身體:
{
"setting_type": "call_to_actions",
"thread_state": "existing_thread",
"call_to_actions": [
{"type": "web_url",
"title": "test",
"url": "https://test.com"
},
{
"type": "postback",
"title": "Help",
"payload": "help"
},
{
"type": "postback",
"title": "Website",
"payload": "web"
}
]
}
您可以在文檔中閱讀有關持久菜單的更多信息: https : //developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu
您可以形成下面給出的請求正文:
{
"get_started":{
"payload":"<GET_STARTED_PAYLOAD>"
},
"persistent_menu":[
{
"locale":"default",
"composer_input_disabled": true,
"call_to_actions":[
{
"title":"Menu",
"type":"nested",
"call_to_actions":[
{
"title":"Pay Bill",
"type":"postback",
"payload":"PAYBILL_PAYLOAD"
},
{
"title":"History",
"type":"postback",
"payload":"HISTORY_PAYLOAD"
},
{
"title":"Contact Info",
"type":"postback",
"payload":"CONTACT_INFO_PAYLOAD"
}
]
},
{
"type":"web_url",
"title":"Latest News",
"url":"http://www.messenger.com/",
"webview_height_ratio":"full"
}
]
},
{
"locale":"zh_CN",
"composer_input_disabled":true,
"call_to_actions":[
{
"title":"Pay Bill",
"type":"postback",
"payload":"PAYBILL_PAYLOAD"
}
]
}
]
}
您可以跟進的 uri 是:
https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.