Skip to content
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

Account linking webhook isn't parsed to response #13

Open
spencerldixon opened this issue Aug 2, 2017 · 3 comments
Open

Account linking webhook isn't parsed to response #13

spencerldixon opened this issue Aug 2, 2017 · 3 comments

Comments

@spencerldixon
Copy link

When using account linking, Facebook sends a response like this (with a little variation between linking an account and unlinking one)

%{"entry" => [%{"id" => "12341234",
     "messaging" => [%{"account_linking" => %{"status" => "unlinked"},
        "recipient" => %{"id" => "13241234"},
        "sender" => %{"id" => "12341234"},
        "timestamp" => 12341234}], "time" => 12341234}],
  "object" => "page"}

Currently this package ignores the request, but I'd like to be able to handle it in my application. I traced it back to the FacebookMessenger.Response.parse function, and it just looks like it has no structure specified for this specific webhook. What would be the best way to add this?

I could pattern match with a new parse function like...

def parse( %{"entry" => [%{"messaging" => [%{"account_linking" => _}]}]} = param ) when is_map(param)

But that looks pretty hideous. It would be nice to keep the same parse function and just add to the structure.

Thoughts? What is the best way to go about supporting account linking webhooks? I would be happy to work on a PR for this as I'm using it for a project at the moment

@spencerldixon
Copy link
Author

Would an account_linking key in the messaging struct be appropriate? This will contain a map like %{"authorization_code" => "12341234", "status" => "linked"} and will be nil for regular messages

@makefunstuff
Copy link
Collaborator

Account linking is something new as far as I see. Would be nice to have support parsing of this type of payload.
Also we need to rethink how to make design of internal structs more flexible. Can you elaborate?

@spencerldixon
Copy link
Author

The first thing that would need doing is adding the concept of buttons here, as facebook requires account linking requests to be initiated through a specific "log in" button.

Then we'll need a way to handle facebooks callbacks for a user connecting/disconnecting their account with the bot. I think something similar to the message_received that can be added to the controller in your project, like a account_linking_received call that will allow you to take the information from facebooks callback, and do the linking with the account in your project.

Hope this makes sense, I'm fairly new to Elixir but I'm using this for a bot and I've hacked together both features for now, but I'd be keep to get better support for them, especially buttons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@makefunstuff @spencerldixon and others