Chatbots Magazine Become a Writer Intro to Chatbots

Best way to handle multiples Facebook chatbots with one single Webhook

Hi everybody.

I’m working on a web that will help people to create bots without programming knowledge.
My first approach is to have a single webhook for all the bots that people want to create and dynamically serve the request depending of which pageid i receive.

What do you think about this way to handle multiples chatbots?

Thank you very much for any help that you can provide.

I was thinking about doing the same thing…
It seems like it’s not that easy to be implemented…

Which bot framework are you using?

Yeah, you can do it that way… Going to get a bit messy on the server since you will have to make sure to read in the page id then based on what that is set the correct page token for api requests so bot knows where to send it’s messages.

Are you trying to create a chat bot creation tool like Chatfuel and all the other ones out these days? If yes I would recommend using one of those services to get an idea how they do it so you are not reinventing the wheel.

1 Like

Hi Joseph.
I agree with you.
Im going to check Chatfuel to get some ideas.
Do you know more services like Chatfuel?
Thank you very much.

Hi @eyal.zoref
Im not using any framework yet.
Im just thinking about the architecture of the application :slight_smile:

WHi Joseph,

I still haven’t got the way you are connecting your bot to any Facebook page out there w/o the need to configure the page token and bot secret per page?

I am using nodejs based bot using botkit framework. I am considering to move to Microsoft Bot Kit…

Hi

We handle all our bots on a single url
Just pass an extra parameter to the webhook (i.e. ?app=XXXXXX)
So we keep the logic in a single place and scale to multiple servers efficiently

Nice solution @maxi
Thank you very much for share your solution with us.
First i thought to use only the facebook page id but in the future i want to implement more platforms like slack and telegram and in this scenario your solution fit very well.
Have a nice day.

We manage several bots on the same weebhook
We distinguish the bot using the app parameter via $_REQUEST
what is more we filter the page of each bot using the message object Facebook sends.

We started with a multiple webhook approach but it was very hard to mantain

Hope this helps

1 Like

Hi @maxi,

Thanks for sharing your experience.
Which frame work are you using for the bot?

We are using nodejs botkit and we went
on the same approach to pass the appId via URL of the web hook. The question is can we do it w/o touching the botkit code? (It is preferred to keep the framework as is for easy future updates). Does anyone had experience with that?

LAMP Framework

We dont user botkit (yet)

You can store the pageID/access_token.
In your webhook, check if receiptid = pageid and set the access_token for that interaction.
Simple like that.

Going to try it, thanks!

I have gotten this to work well on RoR. Started with multiple apps / webhooks but it got unwieldy. Now I’ve got a really nice set-up that only requires 10 min to set up a new bot. Can share more if you’re interested.