Najmuzzama Khan
Ritik Tripathi
Instagram Integration
Table Of Contents
Facebook Console
Code Flow
First, We Need To Create An App, And Then Select It.
Basic Overview Of Our App Console
Cont…
Different Roles To Operate On The App
Requirements for Administrator’s account
Requirements for Tester’s account
Webhooks
Webhooks To Be Used, First Need To Be Subscribed
Messaging Webhooks Field | Description |
message_reactions | A notification is sent when a customer reacts to a message sent by your business. |
messaging_seen | A notification is sent when a customer reads a message sent by bot, for Instagram Messaging conversations. |
messaging_postbacks | A notification is sent when a customer clicks a postback button, Get Started button, or persistent menu item for Messenger conversations |
Available Messenger Webhook event
messages | A notification is sent when your business has received a message from a customer from any conversation entry point. |
messaging_handover | A notification is sent when a change has occurred during the Handover Protocol |
standby | A notification is sent when a conversation is idle for an app during the Handover Protocol |
To Set Up A Webhook, Developers Need To Provide A Callback Url And A Verify Token.
Attaching The Callback Url And Adding Verify Token
App Review
Basic Data Flow
Message received from requestHandler
We make sockets and userData object and pass to OCS entry point
Message is processed
Sent to IG through responseHandler
Flow Chart
What We Need In Env For Integration
An Endpoint To Receive Webhooks Notifications From The Messenger Platform
File- App.js
Validating Verification Requests
File- Botly.js
Whenever the endpoint receives a verification request, it must:
What After Configuring Webhook ?
File- Botly.js
initial point of receiving request
Handlemessage Function Where Different Functionalities Are Handled
File- Botly.js
Only functionalities which are handled in IG till now
Different Types Of Events Get Emitted By These Functions Such As Message, Postback etc.
File- Botly.js
To Capture “Message” Event From The Messenger Platform
File- igBotManager.js
Similarly, we handle the "postback" event from the Messenger Platform, which is triggered when a user interacts with a button that has text data
File- igBotManager.js
File- igBotManager.js
What Is sendAction Method?
File- socket-functions.js
After processing from ocs, emitMsgToIgclient function is called from socket-functions.js for instagram
Multiple Types Of Messages Can Be Handled And Sent To Instagram Based On The Generated Message From Our Backend.
Multiple Types Of Messages Can Be Handled And Sent To Instagram Based On The Generated Message From Our Backend. (Example)
File-igBotEmitter.js
Quick Replies
Size Limit Of Different Message Types Over Instagram
Text Messages | 1,000 characters |
Audio Files | 25 MB |
Documents | 100 MB |
Images | 8 MB |
Videos | 25 MB |
How To Handle Multiple instagram Pages
1. We create a map called "IG_access_token_map" that stores key-value pairs.
2. The key is "Recipient_Id" and the value is "Access_Token".
3. To determine from which ID we need to send the response, we convert the senderId to "senderId_recipientId".
4. We then check whether this recipientId exists in our map. If it does, we retrieve the corresponding access token and add it to the options object for sending to Instagram.
5. The options object should be structured as follows.
File-igBotEmitter.js
What other features can we add?
What is Ice Breakers?
What other features can we add?
What is the Persistent Menu?
Problem With Persistent Menu
Solution- existing users need to reset their chat history