This is my first question, so please let me know if I am doing something wrong. I tried to build a simple facebook messenger bot using the 'messenger-ruby' gem (https://github.com/netguru/messenger-ruby). I installed the gem successfully, but I think I don't really get how to send / receive messages.
In detail, I followed all the steps in the readme:
- get page access token
- create messenger.rb as outlined in the readme
- added the routes exactly as in the readme
- created the messenger_controller.rb as in the readme
- set up webhooks successfully as in the readme
- visited /messenger/subscribe to subscribe
This all worked so far, at https://developers.facebook.com/apps/.../messenger I see a green check under Webooks and see my page under Subscribed pages.
I did not do the "App Review for Messenger".
Now the problem: I tried to send a standard reply to every incoming message. I put the code from the readme under #components into messenger_controller.rb:
# YOUR_APP/app/controllers/messenger_controller.rb
class MessengerController < Messenger::MessengerController
def webhook
#logic here
if fb_params.first_entry.callback.message?
Messenger::Client.send(
Messenger::Request.new(
Messenger::Elements::Text.new(text: 'some text'),
fb_params.first_entry.sender_id
)
)
end
render nothing: true, status: 200
end
end
But when one of the page admins sends a message to the page, nothing happens. I looked in the logs, but don't see the POST request I'd expect.
When use my browser to visit https:/.../messenger/webhook, I see "Invalid verify token", and in the logs it shows the following:
Started GET "/messenger/webhook" for xxx.xxx.xxx.xxx at 2016-07-22 14:39:52 +0000
Cannot render console from xxx.xxx.xxx.xxx! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Messenger::MessengerController#validate as HTML
Completed 200 OK in 10ms (Views: 0.3ms | ActiveRecord: 0.0ms)
I guess that's ok, but I am not sure.
I'm sure I probably made a simple mistake, but I was reading the docs all day and couldn't find a solution. I'm not even sure what the problem is, as I'd expect to find the POST request in the logs...
Any help would really be appreciated. And please let me know how I could improve my question.