-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal to support multi page bots #137
base: master
Are you sure you want to change the base?
Conversation
Thanks @ntgx! PR looks good to me at a first glance, I'm not a huge fan of passing around yet another param to basically every method on the API, but I understand the need for doing so. I'll have to do some more testing before merging this, but this is looking great. Thanks a lot! |
+1, You know we dont need accessToken when we set webhook and any other express things when starting the bot server.. so we can omit accessToken at startup, this feature will be very much helpful in a multipage app where a new page can be added or removed on the fly.. |
Please check my request @Charca |
actually we dont need to do any change as we just use the accessToken that is set to the bot instance, |
@mahmed0715 I don't think overwriting the |
yeah you are right @Charca , but i think overwriting in right place could be good if possible. need to check if I can get things done, otherwise that solution is okay. I will overwrite exactly before call to fb api..will see.. |
Ran into an error while running this code. When pressing 'Get Started' bots would send back a number of messages equal to the number of times the for loop ran. Is it possible to set the get started button for multiple pages?
|
Hey @DevinODowd are you still having this problem? I do something very similar and it's working fine for me |
Had the same issue as #125 and this is my attempt for a fix. I've been testing it for the past few days and everything's working so far. All tests pass and it doesn't create any breaking changes for people using it for one page. Let me know what you think about the approach :)
Anyone who wants to support multiple pages just needs to pass an object instead of a string to the access token option in the following format and they're good to go
This lets you handle messages from both pages exactly like you used to and if you want to send different messages to different pages you can just check the value on
chat.pageId
firstEven though all the methods on the
chat
object stay the same you have to pass pageId for some methods onbot
if you plan to support multiple pages:The functions that require accessToken in BootBot.js just call _getAccessToken(pageId) which looks like
handleFacebookData(data)
gets the pageId from each entry and passes it to all the event handlersthis
super()