We receive many questions about Account Linking in Chatfuel.
This article will show you a slightly different (easier) way of implementing this functionality as we find it hard to follow the existing procedures involving 3 backends – yours, Facebook’s and ours.
What you’ll be able to do using Account Linking:
- Match the {{messenger user id}} attribute to your website’s logged in users
- Utilize users’ preferences from your website to fine-tune the bot’s experience
- Pass back users’ preferences from the bot to your website
Here is how:
- Create a card with a button leading to your website’s auth URL. Put {{messenger user id}} attribute to the URL. Example: https://yourdomain.com/auth_page/?user_id={{messenger user id}}
- If the user is not authorised on your website, let them log in. Otherwise, go to step 3.
- Now your user is authorized on your website and you know their {{messenger user id}}. Viola! Store the user’s {{messenger user id}} in your website’s database.
- Display a suggestion to close the webview and return to the bot or close the webview using Messenger Extensions.
- Inform the user that Account Linking has successfully finished via a Broadcasting API call.
Now after each user action, you want to store, you may pass the action’s result to your backend via the JSON API plugin, matching the user by {{messenger user id}}.
Vice-versa you can personalize your bot’s behaviour using the JSON API plugin that will load customized data from your website.
Additionally, you can send a personalised broadcast to any of your linked website users via the Broadcasting API.