botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
71 stars 83 forks source link

Allow nested menu in persistentMenuItems #99

Closed daehli closed 7 years ago

daehli commented 7 years ago

I try to add a Nested menu in BotPress. With the UI it's impossible to add a NESTED menu. So I created a botfile-messenger.js to but all me config.

The file look like this.

module.exports = {

  'botpress-messenger':{
    persistentMenu: true,
    persistentMenuItems:[
      {
        "title":"Menu category",
        "type":"nested",
        "call_to_actions":[
          {
            "title":"MENU_CATEGORY",
            "type":"postback",
            "payload":"MENU_CATEGORY"
          }
        ]
      },
      {
        "title":"Add outgo",
        "type":"nested",
        "call_to_actions":[
          {
            "title":"Quick outgo",
            "type":"postback",
            "payload":"QUICK_OUTGO"
          },
          {
            "title":"add outgo",
            "type":"postback",
            "payload":"ADD_OUTGO"
          }
        ]
      }
    ],

    displayGetStarted:true,
    greetingMessage:'Tools to manage the outgo of a freelancer',
    accessToken: process.env.ACCESS_TOKEN,
    appSecret: process.env.APP_SECRET,
    applicationID: process.env.APPLICATION_ID,
    hostname:process.env.HOSTNAME,
    trustedDomains:[
      process.env.URL_BASE,
      'https://ledger.localtunnel.me/',
      'https://ledge.localtunnel.me/',
      'https://my-accounting-pal.herokuapp.com',
    ],
    chatExtensionHomeUrl:{
      'url':process.env.URL_BASE,
      'webview_height_ratio':'tall',
      'in_test':true
    }
  }
}

Went a press SAVE on the UI, Botpress return me this message:
An error occurred during you were trying to save configuration: Error setting persistent menu An error has been returned by Facebook API. Status: 400 (Bad Request) (#100) Invalid keys "call_to_actions" were found in param "call_to_actions[0]".

So a decide to check me call_to_actions. So a take the example menu in Facebook. Botpress UI returns me the same message.

So a make a simple persistent menu with the UI to check on Botpress handle it. I have made a CURL(GET) call on my application to see the data.

{
   "data": [
      {
         "persistent_menu": [
            {
               "locale": "default",
               "composer_input_disabled": false,
               "call_to_actions": [
                  {
                     "type": "postback",
                     "title": "test",
                     "payload": "test1"
                  }
               ]
            }
         ]
      }
   ]
}

I have made another CURL call with a nested Menu inside. I take the example on the facebook doc

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://petershats.parseapp.com/hat-news",
          "webview_height_ratio":"full"
        }
      ]
    },
    {
      "locale":"zh_CN",
      "composer_input_disabled":false
    }
  ]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<YOUR_ACCESS_TOKEN>"

and the response was this.

{
   "data": [
      {
         "persistent_menu": [
            {
               "locale": "default",
               "composer_input_disabled": true,
               "call_to_actions": [
                  {
                     "type": "nested",
                     "title": "My Account",
                     "call_to_actions": [
                        {
                           "type": "postback",
                           "title": "Pay Bill",
                           "payload": "PAYBILL_PAYLOAD"
                        },
                        {
                           "type": "postback",
                           "title": "History",
                           "payload": "HISTORY_PAYLOAD"
                        },
                        {
                           "type": "postback",
                           "title": "Contact Info",
                           "payload": "CONTACT_INFO_PAYLOAD"
                        }
                     ]
                  },
                  {
                     "type": "web_url",
                     "title": "Latest News",
                     "url": "http://petershats.parseapp.com/hat-news",
                     "webview_height_ratio": "full"
                  }
               ]
            },
            {
               "locale": "zh_CN",
               "composer_input_disabled": false
            }
         ]
      }
   ]
}

After this, I just enter the information in my config file and the Botpress UI still sent me an error.

I hope a give enough information to reproduce the error.

Thank You!

daehli commented 7 years ago

I but this Issue in the wrong botpress