Search code examples
phpfacebookherokudropboxfacebook-messenger-bot

Messenger bot broken after renaming it


  • I have a Messenger bot hosted on Dropbox, and deployed on Heroku.
  • It worked fine.
  • I renamed it on Heroku, then also renamed it (to match that change) on developers.facebook.com
  • It is no longer working (doesn't reply to any command, while it did reply to commands when it worked).

What other setting should I update or check?

I can post the code, but there was no code change at all - from when it worked, until it broke - so that probably won't help.

Edit:

When trying to generate a new token, I get:

Invalid Scopes: manage_pages, pages_messaging, pages_messaging_phone_number, pages_messaging_subscriptions. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions

Edit: Making the bot private ("developer mode") allowed me to generate a new token. I pushed the new token to Dropbox and Heroku, and the bot started responding to commands again (working), but making it public broke it again.

Edit: I now see that under the Bot's page, in Messenger > Settings, it says that I need permission to use the "API Send (pages_messaging)". I've sent a request for that...

Are such permissions always required for a Bot to work?

  • I'm not trying to access any user info (not that I know of), and the docs said that one can immediately make a bot public, unless it needs to access private info. All my bot does is reply certain messages to certain commands.

Notes:

  • I never tested it with an account other then mine (the developer account for the bot), so it can be that it never "worked" while public. It is newly made.
  • By now, the title of this post maybe should change to "bot broken after making it public", but I'm not sure about that being the case just yet.

Solution

  • TL;DR

    Renaming shouldn't be an issue, provided you rename it in all necessary locations (including but not necessarily limited to: developers.facebook.com, Heroku).

    In long:

    • It turns out I never tested the bot from an account other than the admin, so it never "stopped working", rather was never published yet. Renaming is not a problem (as long as you also rename it on developers.facebook.com)
    • In order to have it work for other accounts (I.E. make it public), you need to request permission to use pages_messaging. Scrolling down on the "Messenger" page (on developers.facebook.com), you can initiate the request, and it will prompt you to fill any required information, such as your app's privacy policy, icon, as well as temporarily add several accounts as testers for your app (these accounts will be provided to you in that prompt), plus adding those same accounts as editors of the Facebook page you want to use the bot on.

      Notes:

      • I'm not sure if pages_messaging is required for a Facebook bot altogether, or only if one also wants the bot to be available on the Messenger platform, but because that's what I wanted for my bot, I selected that feature when setting up the bot to be public and initiate the request.
      • Initiating a request will toggle your bot back to "private" (invisible to non-admin accounts).
      • A useful sanity check (which helped me a few times) if things break and you are not sure why, is generating a new token by "selecting" your page again under the App's settings (don't forget to actually use that token and push changes).