bootbot
bootbot copied to clipboard
updating readme example of 'handleFacebookData' function
The current 'handleFacebookData' example in the readme is incorrect, since it passes individual message objects to the function but the function is expecting to parse the array of messages.
There is a bug in the docs for this method, but your example doesn't show why this method actually exists. The whole point is to be able to switch on bots so you can have multiple pages hosted by the same facebook app. So either:
- This method doesn't work as it should, ie. you can receive messages for more than one facebook page in one request from facebook.
- This method works but and docs are wrong but the example needs to show how to get the page id from the incoming request and then send the whole array to the
handleFacebookData
method
In case 1. this PR isn't needed, what is needed is an API fix.
In case 2. this PR needs to be changed to show the actual use case.
In either case, there should be a method that takes an individual message, maybe handleFacebookMessage
or something that does what the original example shows.
If you want to do that, I am unlikely do be building a bot for the next month at least, so it would be welcomed.
Thanks for trying to make the library better! We really appreciate it.
Ok I updated the example. It's a naively/simple example that assumes response items exist and that facebook wouldn't batch entries from different pages in one post request, which may not be true. But its example code...
Also, just to say, running multiple bots on one instance is actually not my use case for this function. I am using this function to incorporate bootbot into an existing express application, which is something that isn't covered in the docs/github issues (that I could find), and I imagine other people are trying to do as well.
@mraaroncruz the new docs look good to you?