I have taken a long to blog this, but we did the implementation almost 1 year back.
Business use case(s) :
Business use case(s) :
- You want to send SMS with m.me link and once clicked, the bot should understand the context and initiate the chat, instead of user sending "Hi"
- You have a campaign and a link on web, and once user clicks it, you want bot to start the conversation without user typing.
Solution
Use FB ref param and take the action needed.
Prerequisite :
Your FB app/page is configured i.e. by default you have deep link from fb e.g. if my page name is digitaldemofortelcos , my default deep link is m.me/digitaldemofortelcos
Please read about ref param on facebook developer docs.
Your architecture for AI is as shown in one of my previous blog here : "Architecture for chat-bots"
Steps :
- In order to understand the steps, first you need to understand the flow.
- As soon as user clicks the link, the redirection is done. If you add a ref param e.g. m.me/digitaldemofortelcos?ref=new_ref_check, the webhook will receive the event type as referral and you can capture the event and do some action as per your business need.
- In Node JS, you can capture the event and do the relevant action ( e.g. send some text to API.AI based on the value of Ref or reply to the user using FB graph API call).
- Goto your processEvent(event) function
- Check the referral event in web-hook and do anything what you want here
- You will receive the JSON referral and inside it the ref ( the text in the example above i.e. new_ref_check will come inside event.referral.ref in the JSON structure)
if(event.referral && event.referral.ref)
{ // Your code here.You can check the referral text and reply to user using FB graph send // message or send customized message to AI platform to reply to user based
// on the mapped intent of this customized text
}
That's it. Try it yourself and enjoy.
Comments
Post a Comment