FB Messenger持久菜单嵌套在嵌套中?

时间:2018-01-11 18:12:30

标签: facebook facebook-messenger

我在嵌套菜单中获取嵌套菜单时遇到问题。有谁知道你是否只能降级?或者你可以做两个吗?

我这里有一个嵌套在嵌套中的菜单 - 但我一直收到这个错误: {"错误":{"消息":"(#100)需要其中一个参数:get_started,persistent_menu,target_audience,whitelisted_domains,greeting,account_linking_url,payment_settings,home_url&# 34;,"类型":" OAuthException""代码":100," fbtrace_id":" H1RDxO9wOcL"} }

这是我的代码

"persistent_menu":[
>   {
>     "locale":"default",
>     "composer_input_disabled": false,
>     "call_to_actions":[
>       {
>         "title":" Menu",
>         "type":"nested",
>         "call_to_actions":[
>           {
>             "title":"About",
>             "type":"postback",
>             "payload":"ABOUT"
>           },
>           {
>             "title":"Tips",
>             "type":"nested",
>             call_to_actions":[    
>                     {
>                     "title":"Hours",
>                     "type":"postback",
>                     "payload":"Hours"
>                     },{
>                     "title":"Restroom",
>                     "type":"postback",
>                     "payload":"Restroom"
>                     },{
>                     "title":"Other",
>                     "type":"postback",
>                     "payload":"Other"
>                     },
>               ]
>           },
>           {
>             "title":"Leaderboard",
>             "type":"postback",
>             "payload":"Leaderboard"
>           }
>         ]
>       },
>     ]
>   }
> ]
> }' "https://graph.facebook.com

3 个答案:

答案 0 :(得分:0)

使用您自己的页面访问令牌POST到Messenger Profile API。您应该是页面管理员来执行此操作。

https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>

以下数据

{"persistent_menu":[{"locale":"default","composer_input_disabled":false,"call_to_actions":[{"title":" Menu","type":"nested","call_to_actions":[{"title":"About","type":"postback","payload":"ABOUT"},{"title":"Tips","type":"nested","call_to_actions":[{"title":"Hours","type":"postback","payload":"Hours"},{"title":"Restroom","type":"postback","payload":"Restroom"},{"title":"Other","type":"postback","payload":"Other"}]},{"title":"Leaderboard","type":"postback","payload":"Leaderboard"}]}]}]}

我在自己的机器人上测试过,希望这对你也有用。感谢。

答案 1 :(得分:0)

https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api/persistent-menu

永久菜单的要求:

  • 设置一个开始按钮。
  • 拥有与机器人相关联的页面的“管理员”角色。

如果您没有创建任何 get_started 按钮,则应创建一个类似下面的curl请求。 get_started按钮是创建persistent_menu的必要条件。

curl -X POST -H "Content-Type: application/json" -d '{ 
  "get_started":{
    "payload":"START_PAYL"
  }
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<API_ACCESS_TOKEN>"

如果您已有get_started按钮,现在可以在curl请求下运行以创建 persistent_menu

curl -X POST -H "Content-Type: application/json" -d '{
  "persistent_menu":[
    {
      "locale":"default",
      "composer_input_disabled": true,
      "call_to_actions":[
        {
          "title":"My Account",
          "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":false,
      "call_to_actions":[
        {
          "title":"Pay Bill",
          "type":"postback",
          "payload":"PAYBILL_PAYLOAD"
        }
      ]    
    }
  ]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<API_ACCESS_TOKEN>" 

重要说明:持久性菜单的顶级菜单项数组。 最多允许3个项目。 最多支持两个嵌套菜单。

答案 2 :(得分:0)

您可以使用Botsnacks快速解决此问题以及更多问题。 https://github.com/4handheld/botsnacks。 一切都是自动化的,包括入门有效载荷,菜单等。