Cannot enable Facebook Messenger Channel

I followed the document (https://botpress.com/docs/channel/messenger) to enable facebook messenger in my bot. My bot still work fine after I enabled messenger from global botpress.config.json but botpress doesn’t start when I configured appSecret and verifyToken in channel-messenger.json file. It stops at
Server Running in DEVELOPMENT MODE
when I add appSecret and verifyToken to the messenger config file. If I disable messenger channel again. It works fine again. Please kindly help me. I can’t find another tutorial or documentation about the messenger configuration in botpress.

Hi @Aung_Pyae_Kyaw and welcome to the community

Yes, I was able to reproduce your issue, and a PR was proposed.

However, I didn’t fully test the channel, I guess you can manually change channel-messenger/src/backend/index.ts, if you can’t build Botpress.

1 Like

@asashour After I updated to the new version 12.7.0, I can start the messenger module successfully. I also setup the facebook webhook and now webhook is now verified. But after I restart the server to reload the messenger module, I’m experiencing Cannot mount bot “bot name”. The following is the output of the log.

Cannot mount bot "testbot" [Error, while mounting bot in module channel-messenger: Error: Request failed with status code 400]
STACK TRACE
Error: while mounting bot in module channel-messenger: Error: Request failed with status code 400
    at ModuleLoader.<anonymous> (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
    at Generator.throw (<anonymous>)
    at rejected (/snapshot/build-linux/out/bp/core/module-loader.js:0:0)
    at tryCatcher (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/ubuntu/botpress/modules/.cache/module__7ec989fa164d263397ffcf9718bf2ce169c717ce84c714a6996229edd8bd7253/node_production_modules/bluebird/js/release/async.js:15:14)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)

I appreciate your help. Thank.

Sorry. It’s resolved. Messenger module now function properly. But I don’t know what cause that request fail error.

Hard to tell, maybe there was a connection error. Unless it’s reproducible, it’s hard to investigate

okay, The above status code 400 response code is from facebook. Facebook responses status code 400 (Bad Request) if the persistentMenu configuration in messenger config file is invalid. Thank everyone.

I am getting the same error on my installations (12.4.2 and above)

When I run any bot with the messenger module on and correctly set I get the following:

CHATBOT-SERVER1+admin@chatbot-server1 MINGW64 /c/Chatbot Deployments/ProjectSmartiesFastFoodv1.01/ChatbotFacebookChannel
$ ./bp
16:53:59.792 Launcher ========================================
                                  Botpress Server
                                   Version 12.4.2
                                      OS win32
                      ========================================
16:53:59.797 Launcher App Data Dir: "C:\Users\admin\botpress"
16:54:03.762 Launcher Using 21 modules
                      ⦿ MODULES_ROOT/analytics
                      ⦿ MODULES_ROOT/basic-skills
                      ⦿ MODULES_ROOT/builtin
                      ⦿ MODULES_ROOT/channel-messenger
                      ⊝ MODULES_ROOT/channel-slack (disabled)
                      ⊝ MODULES_ROOT/channel-teams (disabled)
                      ⦿ MODULES_ROOT/channel-telegram
                      ⦿ MODULES_ROOT/channel-web
                      ⦿ MODULES_ROOT/code-editor
                      ⦿ MODULES_ROOT/create-nolti
                      ⦿ MODULES_ROOT/create-zi-cool-graphic
                      ⦿ MODULES_ROOT/create-zune-game
                      ⦿ MODULES_ROOT/examples
                      ⦿ MODULES_ROOT/extensions
                      ⦿ MODULES_ROOT/history-of-fast-foods-interactive
                      ⦿ MODULES_ROOT/hitl
                      ⦿ MODULES_ROOT/horoscope
                      ⦿ MODULES_ROOT/misunderstood
                      ⦿ MODULES_ROOT/nlu-extras
                      ⦿ MODULES_ROOT/nlu-testing
                      ⦿ MODULES_ROOT/nlu
                      ⦿ MODULES_ROOT/qna
                      ⦿ MODULES_ROOT/testing
                      ⊝ MODULES_ROOT/uipath (disabled)
16:54:04.856 Mod[nlu-testing] You are using Botpress NLU Regression Testing module which meant to be used only by the botpress team.
16:54:06.680 Server Loaded 21 modules
16:54:06.780 CMS Loaded 27 content types
16:54:08.958 Mod[channel-messenger] Messenger Webhook URL is https://un.dis.closed.com/api/v1/bots/___/mod/channel-messenger/webhook
16:54:21.978 BotService Cannot mount bot "facebook-bot". Make sure it exists on the filesystem or the database. [Error, getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443]
STACK TRACE
Error: getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:50:26)
16:54:21.987 Server Started in 18222ms
16:54:21.987 Launcher Botpress is listening at: http://localhost:801
16:54:21.987 Launcher Botpress is exposed at: https://un.dis.closed.com

The other one is just a simple test bot on the latest version


CHATBOT-SERVER1+admin@chatbot-server1 MINGW64 ~/Desktop/Face-Off
$ ./bp
03/20/2020 16:54:18.032 Launcher ========================================
                                             Botpress Server
                                              Version 12.7.1
                                                 OS win32
                                 ========================================
03/20/2020 16:54:18.038 Launcher App Data Dir: "C:\Users\admin\botpress"
03/20/2020 16:54:21.405 Launcher Using 13 modules
                        ⦿ analytics
                        ⦿ basic-skills
                        ⦿ builtin
                        ⦿ channel-messenger
                        ⦿ channel-web
                        ⦿ code-editor
                        ⦿ examples
                        ⦿ extensions
                        ⦿ hitl
                        ⦿ misunderstood
                        ⦿ nlu
                        ⦿ qna
                        ⦿ testing
                        ⊝ channel-slack (disabled)
                        ⊝ channel-smooch (disabled)
                        ⊝ channel-teams (disabled)
                        ⊝ channel-telegram (disabled)
                        ⊝ nlu-extras (disabled)
                        ⊝ nlu-testing (disabled)
                        ⊝ uipath (disabled)
03/20/2020 16:54:21.407 Server Running in DEVELOPMENT MODE
03/20/2020 16:54:24.437 Server Loaded 13 modules
03/20/2020 16:54:24.668 CMS Loaded 7 content types
03/20/2020 16:54:26.995 HTTP Configured port 801 is already in use. Using next port available: 804
03/20/2020 16:54:27.026 Server Discovered 1 bot, mounting it...
03/20/2020 16:54:27.028 Mod[channel-messenger] Messenger Webhook URL is https://un.dis.closed.com/api/v1/bots/___/mod/channel-messenger/webhook
03/20/2020 16:54:40.046 BotService Cannot mount bot "facebook" [Error, while mounting bot in module channel-messenger: Error: getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443]
STACK TRACE
Error: while mounting bot in module channel-messenger: Error: getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443
    at ModuleLoader.<anonymous> (C:\snapshot\build-windows\out\bp\core\module-loader.js:0:0)
    at Generator.throw (<anonymous>)
    at rejected (C:\snapshot\build-windows\out\bp\core\module-loader.js:0:0)
    at tryCatcher (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\promise.js:725:18)
    at _drainQueueStep (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\admin\Desktop\Face-Off\modules\.cache\module__ccbbfdeb6dbf153b164b74b6bf721fe7b40d254c1ad6ceedb0197c783af5da05\node_production_modules\bluebird\js\release\async.js:15:14)
    at runCallback (timers.js:696:18)
    at tryOnImmediate (timers.js:667:5)
    at processImmediate (timers.js:649:5)
    at process.topLevelDomainCallback (domain.js:121:23)
03/20/2020 16:54:40.056 Server Started in 18649ms
03/20/2020 16:54:40.057 Launcher Botpress is listening at: http://localhost:84
03/20/2020 16:54:40.057 Launcher Botpress is exposed at: https://bude.econet.co.zw

Please help

The URL (https://graph.facebook.com/v3.2/me) is used to connect facebook messenger service from botpress messenger module. It looks like your problem is that messenger module can’t connect to the facebook messenger service somehow .
getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443
But I don’t know for sure. This is just my two cents. I will reply when I find something about your problem.

Okay I have a broad question. Does the application server need internet access (or at least access to graph.facebook.com) for facebook messenger channel. Webchat works fine on this setup but as soon as I enable messenger hell breaks loose. Webhook registration sails through both on the fb application and aon botpress. But the moment the bot with the channel-messenger.json file in its config attempts to mount I get the error below then the bot fails to load and (but all other bots on the server load without channel messenger load with no problem)

Error, while mounting bot in module channel-messenger: Error: getaddrinfo ENOTFOUND graph.facebook.com graph.facebook.com:443

I thought all polling was via dns (but I am not a networking expert). Also is the port I connect with on the internet important or do I only have to consider which ports are open on the public IP.

The reason I ask is that I have had this set-up for some time and everything worked well. But when I revoked internet access to the server everything still worked well except the messenger channel.

Messenger module tries to reach to graph.facebook.com and must keep the connection afterwards.

The machine/server where your Botpress server is hosted should have an access to graph.facebook.com. For this reason, make sure that :

  • Your machine/server has access to internet
  • If you are hosting your Botpress server in a company machine/server, your company proxy allows connection to Facebook (graph.facebook.com), which is generally not the case

Thank you. I forgot to post a response. The issue was caused by case 1 and is now resolved