jgorset / facebook-messenger

Definitely the best way to make Bots on Facebook Messenger with Ruby
MIT License
962 stars 211 forks source link

Multiple bots #150

Closed giolazzareschi closed 7 years ago

giolazzareschi commented 7 years ago

Hi, we are using this gem to make ours customers respond their clients via facebook messenger.

The only thing that we need now it understand how to configure properly to make it happen. The readme configuration about the providers is not clear enough about how it works.

I have some questions about it:

  1. I just need to create a class that implements Facebook::Messenger::Configuration::Providers::Base methods?

When those methos will be called? Cause i put some logger inside

def access_token_for(page_id) 

and its never called and the other methos described in README neither.

  1. where do I need to put this other code

    Facebook::Messenger::Subscriptions.subscribe(access_token: access_token)

We already have the pages numbers and valid access_tokens from facebook for each of the pages that we need but I keep receiving this messasge:

Facebook::Messenger::FacebookError (An active access token must be used to query information about the current user.):

I appreciated any helps. Thanks

jgorset commented 7 years ago

Hi @giolazzareschi!

The only thing that we need now it understand how to configure properly to make it happen. The readme configuration about the providers is not clear enough about how it works.

Did you also configure the gem to use your configuration provider?

Facebook::Messenger.configure do |config|
  config.provider = ExampleProvider.new
end

Either way, how can we make the README more clear as to how it works? It's pretty clear to me, but then again that's coming from the guy who wrote it. 😄

where do I need to put this other code Facebook::Messenger::Subscriptions.subscribe(access_token: access_token)

You just need to run that once, so you don't need to put it anywhere. Just run it from your terminal. I updated the README in #153 so it's more clear how subscribing works.

Facebook::Messenger::FacebookError (An active access token must be used to query information about the current user.):

That's weird. Do you have a stack trace to go with that? I need to see where it's coming from to be able to help.

jgorset commented 7 years ago

I'm closing this pending a stack trace.

giolazzareschi commented 7 years ago

Hi! Sorry for my late reply.

Yes the provider worked as well, I had the keys in api_keys.rb file so I just removed that I started working. Now I have multiple pages responding, but I still depend to get access_token from front-end via Facebook Javascript Login, store it and from times to times get a new access_token.

Well about the README, for me wasn't clear which files I should create for this problem, where put the proivder configuration. I'm not a ruby expert so I took a while to understand those things.

Thank you very much I appreciated the help and your work is very awesome. Regards.

jgorset commented 7 years ago

Glad you got it to work, @giolazzareschi!