Connect your Instagram Page

Follow the steps in this article to subscribe an Instagram page to our messenger system, using the Facebook Messenger API

Instagram messaging and Facebook messaging are tightly coupled. To have an Instagram page set up in Social25 it is required to follow the following guide first https://gomeddo.atlassian.net/wiki/spaces/SOC/pages/1623916545

Connect your Instagram page to your Facebook page

To make use of Instagram messenger, the Instagram page needs to be connected to a Facebook page.

  1. Login to your Facebook page and go to Settings in the left sidebar

  2. Click Instagram in the left sidebar

  3. Click the Connect Account button. A popup should open

  4. Enable the Allow access to Instagram messages in Inbox toggle and click Continue

  5. Login to Instagram

Your Instagram page is now connected to your Facebook page.

Getting your Instagram page id

The Instagram page ID is necessary to differentiate your messages from other pages. Unfortunately, there is no straightforward way to get it. To retrieve it the following steps need to be followed:

  1. Go to your Instagram page and append ?__a=1&__d=dis to the URL. It now should look something like this https://www.instagram.com/<username>/?__a=1&__d=dis. Press Enter.

  2. A JSON document will open. Search the page with Ctrl+F (or CMD+F on mac) for fbid.

  3. fbid will be highlighted. After fbid there is a number. This is your Instagram page ID. Copy this number and save it somewhere.

Add Instagram messaging to your Facebook App

  1. Provided you have followed the guide to https://gomeddo.atlassian.net/wiki/spaces/SOC/pages/1623916545, go to developers.facebook.com and log in

  2. Go to the App to which the Facebook page you used to connect your Instagram page with, is connected.

  3. Messenger will be a listing under Products in the left sidebar



  4. Expand Messenger and click on Instagram Settings

Generate an Instagram page access token

To integrate the Instagram API, an access token is needed. This process is similar to generating Facebook page access tokens, however, a different token will be generated for Instagram.

  1. Click on the Add or Remove Pages button

  2. A popup opens, log in with your Facebook account

  3. Select the Instagram page you want to connect and press Next

  4. Select the page the Instagram page is connected to and press Next

  5. Enable all the toggles listed and press Done

  6. Click OK

  7. Press Generate Token. A token is generated once and cannot be retrieved. If you lose the token you can regenerate it, however, this will break any integration using this token.

  8. Click I understand and then Copy

  9. Paste the token with the page ID you saved previously

  10. Go To Social25 Configuration Wizard

  11. Go To Channels

    1. Select instagram

    2. Input the required fields here and press save.

      image-20240222-091337.png

 

App Info

Page Access Token: copied in step 7 of the Generate a Instagram page access token section



App ID: find it on the dashboard of the app



App Secret: find it on the Settings > Basic page of the app, click Show next to the secret



Webhook URL: The webhook URL you've linked the app to

Page Info

Page ID (should be a number): The id saved in step 3 of the Getting your Instagram page id section



your page's URL for verification purposes

 

 

Configure Webhooks

To proceed with this section, please wait for confirmation from the Social25 team that your page was successfully configured.

  1. Under Webhooks, click on Add Callback URL

  2. Enter the following details and configure the Webhook Subscriptions

Callback URL

https://social25.herokuapp.com/v1/webhook/instagram/

Verify Token

fkq8rzmB8rg5mhPYfVBCsFPGTzJittCN

 

 

If the environment you're setting up is not your production environment you can use our Staging or Acceptance environment. To connect to either of those please use the following details:

Staging
The staging environment receives release on average 3 days before the production environment and has the same stability as production.

Callback URL

https://social25-staging.herokuapp.com/v1/webhook/instagram/

Verify Token

727a5a606272437ba00d99489516d085

Acceptance
Acceptance receives releases before staging and can be used to test new functionalities of Social25 before we push them to Staging.

Callback URL

https://social25-acc.herokuapp.com/v1/webhook/instagram/

Verify Token

e386d6fc84d44465b5dd0c7335b5144e

If you use any of these environments make sure to include this when you provide the Social25 team with the details of the set-up.

  1. Click on Verify and Save

  2. Your Webhooks are now configured and should look something like this

     

  3. Done! You may now start using Social25 to respond to your Instagram messages.

Requesting Instagram Permissions

One of the most important permissions you will need is the pages_messaging permission. Without this permission even if your app status is Live anyone who isn't a developer, tester, or admin of your developer app their messages won't be submitted through the webhook.

If you’re just testing out Instagram you won’t need these permissions. Please note that you won’t be able to send/receive messages on Instagram accounts that have been added to your already existing Facebook App used for Facebook Messenger if you don’t have the permission. Not even if you’re a tester of the application.

  1. Go to https://developers.facebook.com and navigate to your development app.

  2. Navigate to the App Review > Permissions and Features.

  3. Search for instagram_manage_messages click on “Request”.

  4. Search for pages_messaging click on “Request”.

    1. If you already have the pages_messaging you won’t have to add this to the request

  5. Click on “Continue the Request”

  6. Click on the blue arrow in the section “App Verification Details”

    1. Make sure you’ve added a platform to your app. This can be a website with a link to your companies website.

    2. In the Platform Settings settings explain how you’re using the Facebook Messenger App. e.g.

    3. You can leave the Access Credentials area empty as Facebook won’t need to log in for this use case.

  7. Click on the blue arrow in the section “How will your app use the Advanced Access instagram_manage_messages permission?”

    1. Provide a detailed description of how the app utilizes the permission.

    2. Provide a video that showcases how the application utilizes the permission. We’ve provided an example video that you could use.

  8. If applicable. Click on the blue arrow in the section “How will your app use the Advanced Access pages_messaging permission?”

  9. Provide a detailed description of how the app utilizes the permission.

  10. Select a page and explain the flow that is utilized by Agents to answer service cases.

  11. Provide a video that showcases how the application utilizes the permission. We’ve provided an example video that you could use.

  12. If there is no blue checkmark before “Review your app settings” click the blue arrow and complete any open action.

  13. Click on Submit for Review

Testing Instagram

To be able to test Instagram users need to be either an Admin, Tester, or Developer of the Facebook application and their Instagram account needs to be linked to their Facebook account. If neither of the above is true you can utilize the Instagram Tester functionality. To do this follow the next steps:

  1. Go to https://developers.facebook.com and navigate to your development app.

  2. Click on “Add Product”

  3. Add the product called “Instagram Basic Display”

  4. Validate if you see the button “Create new app” if not follow the steps mentioned (which is most likely adding a platform to the basic app settings) to continue.

  5. Click on “Create New App”

  6. Click “Create App”

  7. Navigate to Roles → Roles

  8. Scroll down to the section “Instagram Testers”

  9. Click on “Add Instagram Testers”

  10. Enter the users their Instagram account name

  11. Click on “Submit”

The user should now accept this invite in the Instagram Messaging App. This can be done under:

  1. Navigate to https://www.instagram.com/accounts/manage_access/

  2. Click on “invites to testers”

  3. Click on Approve.

Users added should now be able to send messages to the Instagram account.

Using the Instagram CDN

For Instagram, we’re forced to utilize the Instagram CDN. In the older Social25 packages this is not part of the CSP Trusted Sites so you will have to add this yourself to Salesforce.

  1. Navigate to Salesforce Setup

  2. Go to the CSP Trusted Sites setting

  3. Click on “New Trusted Site”

  4. Enter the “Trusted Site Name” → “Instagram_CDN”

  5. Enter the “Trusted Site URL” → “https://lookaside.fbsbx.com

  6. Make sure “Allow site for img-src” and “Allow site for media-src” are checked.

  7. Click on “Save”

  8. This might take a while to propagate to the entire Salesforce environment but once that is done you can use all Instagram media files.