facebook messenger bot的持久性菜单没有更新到最后的更改

时间:2017-04-11 06:59:02

标签: facebook-messenger-bot botkit

我正在使用botkit来构建我的机器人。我第一次验证我的webhook持久性菜单就是那个例子:

controller.api.thread_settings.menu([
        {
            "type":"postback",
            "title":"Hello",
            "payload":"hello"
        },
        {
            "type":"postback",
            "title":"Help",
            "payload":"help"
        },
        {
          "type":"web_url",
          "title":"Botkit Docs",
          "url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md"
        },
    ]);

我将持久性菜单更改为:

controller.api.thread_settings.menu([
        {
            "type":"postback",
            "title":"Account",
            "payload":"account"
        },
        {
            "type":"postback",
            "title":"News",
            "payload":"news"
        },
        {
            "type": "postback",
            "title": "Contact",
            "payload": "contact"
        },
    ]);

但它已经过了3天而没有改变我的设定。我想知道什么是错的,facebook Messenger何时更新菜单? 我甚至尝试使用curl删除并添加持久性菜单,但没有任何工作。

2 个答案:

答案 0 :(得分:2)

您必须删除会话主题并再次开始,以查看更改是否生效。

此外,FB为此更改了有效负载结构,您需要设置区域设置,并将菜单项放在call_to_actions数组中。

 controller.api.thread_settings.menu([
       { "locale": "default",
         "compose_input_disabled": false,
         "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":"postback",
            "title":"Help",
            "payload":"help"
        },
        {
          "type":"web_url",
          "title":"Botkit Docs",
          "url":"https://github.com/howdyai/botkit/blob/master/readme-facebook.md"
        }
      ]
        }

    ]);

答案 1 :(得分:1)

您需要以下两种方法:removePersistentMenu和addPersistentMenu。

https://github.com/matthewericfisher/fb-robot/blob/master/app.js

请耐心等待,可能需要一分钟时间,请检查控制台是否有响应。

您还需要在facebook messenger中删除与bot的对话。