0

I want to use nested menus for a Facebook bot, but the new API to set the persistent menu does not work.

Even if I remove the nested menu, Facebook returns "success" but the Facebook page does not show the menu.

If I use the old API on thread_settings, then it works. But using the new API I get no menu at all. The new API works for the getting started button, but not the menu.

I have tried everything, and have no idea why it is not working. It returns success but no menu. I am setting the getting started button too.

curl -X POST -H "Content-Type: application/json" -d '{
  "persistent_menu":[
    {
    "locale":"default",
    "composer_input_disabled":false,
    "call_to_actions":[
        {
          "type":"web_url",
          "title":"Test",
          "url":"https://facebook.com"
        }
      ]
    }
  ]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token={{token}}"
James
  • 17,965
  • 11
  • 91
  • 146
  • It is not just that nested is not working, the new API does not work at all, it gives no menu at all. Where as the old API works, not sure if Facebook is caching something from the old API, or you need to set something so you can use the new API, or need to wait longer for the menu to show up with the new API? – James Jun 06 '17 at 18:39
  • I tried creating a new page, and the same issue exists, the new menu APIs do not work at all even though they return "success", the old APIs work. Still using an existing app, did not try a new app yet. – James Jun 07 '17 at 18:25

4 Answers4

2

I found that the Graph API Explorer gave me alot more success than the curl commands.

Just select the page you are posting to in the "Get Token" menu. Set to Post to me/messenger_profile, add field name as "persistent_menu", and the value as your json array.

It will tell you if anything is wrong with your post.

your json should look something like this for nested.

[
  {
    "locale":"default",
    "composer_input_disabled":false,
    "call_to_actions":
    [

      {
        "title":"Menu",
        "type":"nested",
        "call_to_actions":
        [
          {
            "title":"Home",
            "type":"postback",
            "payload":"PHome"
          },
          {
            "title":"Back",
            "type":"postback",
            "payload":"PBack"
          }
        ]
      },
      {
        "title":"Other",
        "type":"nested",
        "call_to_actions":
        [
          {
            "type":"web_url",
            "title":"View Website",
            "url":"https://www.facebook.co.za",
            "webview_height_ratio":"full"
          }
        ]
      }
    ]
  },
]
Matt
  • 33,328
  • 25
  • 83
  • 97
Mrakulis
  • 91
  • 8
  • I tried exactly that, and get "success" from the POST call from the explorer but *no* menu at all – James Jun 12 '17 at 19:54
  • If I use the old API me/thread_settings it works instantly, also the old API gives the response, { "result": "Successfully added structured menu CTAs" } where as the new one just gives { "result" : "success" } – James Jun 12 '17 at 20:08
  • Do you have a Get started button? You have to have one to have a persistent menu. – Mrakulis Jun 13 '17 at 11:27
  • Well the new API for the Get started button does not work either, I get nothing in the page when calling the new messenger_profile API, but get the button when I call the old thread_settings API. – James Jun 13 '17 at 13:06
  • @James in order to test the get started button, you need to make sure to delete all the previous conversations. Get Started button only appears once. So to test it you will have to keep deleting the conversations which you have with the bot. Check the [OnlineSalesAI](https://www.messenger.com/t/OnlineSalesAI) bot. Click on get started and then delete the conversations and reload the page; you will see get started again. Hope this helps! – Kunal Parekh Jun 19 '17 at 06:48
  • Yes, I always do this. The Get Started button and Menu show up when I use the old API, but do not with the new API. – James Jun 20 '17 at 11:16
  • @James Can you post/send me your call. maybe I can help in adjusting it if it needs (Excluding your token) – Mrakulis Jun 22 '17 at 06:46
  • I tried the exact call in the post above, also many variations. – James Jun 23 '17 at 11:48
1

I have tried it and it works. checkout the code here

You can try the bot here: https://www.facebook.com/nautankibot/

I will have to add you as tester if you want to use this bot as its not public.

Screenshot of nested menu in the bot:

screenshot of nested menuenter image description here

It works on fb messenger app as well.

In the above curl call you have not set the type as "nested" in call_to_actions

The above example is taken from fb documentation for menus

Kunal Parekh
  • 419
  • 3
  • 9
  • It is not just that nested is not working, the new API does not work at all, it gives no menu at all. Where as the old API works, not sure if Facebook is caching something from the old API, or you need to set something so you can use the new API, or need to wait longer for the menu to show up with the new API? – James Jun 06 '17 at 18:38
  • Did your bot have a menu with the old API first, or is it a new bot? – James Jun 06 '17 at 18:39
  • I used the new api and it works well. I can see the menu instantly as soon as the call returns success. I was able to see the menu instantly. – Kunal Parekh Jun 06 '17 at 18:41
  • @James its new bot. I didn't had any menu earlier – Kunal Parekh Jun 06 '17 at 18:42
  • May be an issue with having an existing menu. Has anyone been able to upgrade an existing bot with an old menu with the new API? – James Jun 07 '17 at 11:24
  • @James let me try that out with my [another bot](https://www.facebook.com/sokratiForEcommerce/) which has old persistent menu. Will check and let you know. – Kunal Parekh Jun 07 '17 at 11:31
  • I tried you nautankibot link, and the bot has no menu in the chat? – James Jun 07 '17 at 18:27
  • Maybe the new menu does not show up until the app is released? – James Jun 07 '17 at 18:27
  • @James no menu (new or old) will show up until the bot is made public. I can add you as tested to my bot if you want to see the menu. – Kunal Parekh Jun 07 '17 at 18:31
  • my Facebook app was not public before and using the old API the menus showed up, I made it public, but with the new API the menu still does not work – James Jun 07 '17 at 21:01
  • @James who was able to see the menu? I think it will be visible only for you / developers & testers of your app and not anyone else. Can you share the link for your page? – Kunal Parekh Jun 08 '17 at 01:11
  • I have not submitted the app, I am only testing it using the admin user from the page using "view page as visitor". The bot works and replies, but no menu. If I switch to using the old thread API the menu works. https://www.facebook.com/Test-438969169794455/ – James Jun 08 '17 at 15:29
0

Graph API Explorer also worked for me.

I made a mess trying to delete the persistent menu via CURL. (I love terminal). It was easy to resolve using the Explorer.

Just remembering: screenshot using Graph API Explorer

0

you can use this format fb v8

{ "locale": "default", "composer_input_disabled": false, "call_to_actions": [ { "type": "postback", "title": " عرض بالتصنيفات ", "payload": "Category" },

        {
          "type": "postback",
          "title": " عرض اخر اوردر",
          "payload": "PAYBILL_PAYLOAD"
        },
        {
          "type": "postback",
          "title": " عرض المفضلة",
          "payload": "HISTORY_PAYLOAD"
        },
        {
          "type": "postback",
          "title": " الفاتورة كام",
          "payload": "CONTACT_INFO_PAYLOAD"
        },
    
        {
          "type": "postback",
          "title": " عرض الجديد",
          "payload": "WisNew"
        },
        {
          "type": "web_url",
          "title": " فتح القناة",
          "url": "https://www.t.me/jmllaa",
          "webview_height_ratio": "full"
        },
        {
          "type": "postback",
          "title": " كوبون خصم",
          "payload": "CONTACT_INFO_PAYLOAD"
        }
      ]
   
}