Instagram is one of the important business platforms, and for many small companies it is the only place where they sell their services. Many people also use their Instagram feed to find new offers.
You can connect your bot to Instagram so that it could communicate with your clients using:
- Instagram Direct;
- comments to Instagram posts.
There are several ways to connect Aimylogic to Instagram Direct — by connecting the bot directly to Instagram, by using the Wazzup service, or via the JivoChat channel.
If you connect your bot to Instagram via JivoChat, your bot will also receive mentions and replies to your Instagram Stories.
The bot connects to comments via Bitrix24 Open channels.
In this article, you will find out how to connect the bot directly to Instagram Direct.
The Instagram channel supports the following functions:
- sending images;
- sending audio and video files;
- transferring the dialog to the agent;
- integration with CRM systems;
- sending emails and SMS.
Buttons are not supported in this integration.
Connect the bot to Direct
To use Instagram as an inbound channel:
- Create and configure a Facebook Page.
- Create an app on Facebook.
- Add Facebook and Instagram accounts to the app.
- Create an Instagram channel in Aimylogic.
- Set up a webhook.
- Test the bot.
- Go through the App Review process.
- Publish your Page and app.
Create and configure a Facebook Page
Create a Page
To create a Page:
- Proceed to the Facebook main page and select Pages in the sidebar.
- Click + Create New Page.
- Provide the Page information: the Page name and category are required. Then click Create Page.
- After creating a Page, you can add profile and cover photos, and also fill out optional fields.
Set up your Page
Let’s make your Page unpublished.
- Go to Settings in the Manage Page menu.
- Set Page unpublished in the Page Visibility field. Choose The Page isn’t finished yet → Unpublish as a reason. Now only Page admins can see your Page.
Now let’s give admin rights to all the users that will be able to view the dialogs with the chatbot.
- Choose Page roles → Assign a New Page Role.
- Type a Facebook name of the user you would like to give permissions to, choose Admin and click Add.
Connect your Page to an Instagram Business Account
The Page should be connected to your Instagram Business Account.
You can connect only one Page to an Instagram Business Account.
- Proceed to Facebook main page and select Pages → (Your Page name) → Settings → Instagram in the sidebar.
- Click Connect Account.
- In the modal window, allow access to Instagram messages in Inbox and click Continue.
- Log in to your Instagram account and select the Page you are going to connect.
If you already have another Page connected to this Instagram account, you should disconnect it in order to connect a new one.
Configure an app on Facebook
Create an app
- Open the Facebook for Developers page.
- Click Log in and log in to your Facebook account.
- Select Get started on the main page of Facebook for Developers.
- Go through all the steps to create your account on Facebook for Developers.
- After you have created an account, go to the My Apps tab, click the Create App button and select the Business app type. Click Continue.
- Name the app and select Yourself or your own business as the app purpose. Add your Business Manager account and save the settings.
After you have done it, you will be taken to the page of your app.
Add Facebook and Instagram accounts
On the app page, select the Dashboard tab in the sidebar. Find Add Products to Your App section and select Messenger, then go to the Instagram Settings tab.
To add accounts, follow the steps below:
- In the Access Tokens section, click the Add or Remove Pages button.
- The new window for Facebook authorization will open. Click Continue as (your account name).
- Select the Instagram Business Account you are going to use in the integration, then click Next.
- Select the Facebook Page you are going to use in the integration.
- Specify the app permissions. All permissions should be activated so that the integration works correctly. Click Done, and the app will be connected to Facebook. The Page will appear in the Access Tokens section.
If you add the Page that is not connected to the selected Instagram Business Account, this Page will not be added and displayed in the Access Tokens section.
Now, you need to get an access token. Click the Generate Token button next to your Page. In the modal window, enable the I Understand option and copy the token. You will need it when configuring the channel in Aimylogic.
Create a channel
On the bot page in Aimylogic, go to the Channels tab. Select the Instagram channel.
Fill out the fields:
- Access token — paste the access token that you have copied before.
- Name — choose any name you like. You can change it later.
Get a webhook
Click Get webhook under the name of the channel. The webhook URL will be copied to the clipboard.
Go back to the Instagram Settings page and follow the steps:
- In the Webhooks section, click Add Callback URL.
In the modal window, paste the webhook you have copied into the Callback URL field. Paste
justai_verify_tokeninto the Verify Token field. Click Verify and Save.
Click the Edit Subscriptions button. Activate the messages and messaging_postbacks parameters, then click Save.
- Reload the page. Select the Webhooks tab in the sidebar and select Permissions from the drop-down list.
- Click Subscribe to this object and fill out the fields as specified in steps 1 and 2, then click Verify and Save.
- Find instagram_basic, instagram_manage_messages, and pages_manage_metadata permissions. Click Subscribe near each of these parameters.
After you take all the steps, the integration will be ready for testing.
Test the bot
To test the bot, you should add another Facebook account as a tester on the page of the Facebook app.
For doing this:
- Select the Roles tab in the sidebar and click Add testers in the Testers section.
- In the modal window, specify the name or identifier of the tester’s account and click Submit. The account will be added to the section with Pending status.
- Log in to Facebook with the account you have added as a tester, then approve the request for adding the account to the list of testers.
- Log in to Instagram with the account connected to the Facebook account you have added as a tester.
- Go to the page of the Instagram account you have added when configuring the app. Send a message via Direct.
If you have configured everything correctly, the bot will answer according to the script.
Go through the App Review process
To make the bot reply to messages sent from any people, not only those with a direct role on the app, you need to go through the App Review for Instagram Messaging Apps.
First of all, make sure your app does not contradict:
- Messenger Platform Policy;
- Facebook Platform Terms;
- Developer Policies;
- Facebook Community Standards.
Before you submit your app, make sure it functions correctly.
If Facebook is unable to test the app functionality, or the functionality does not work as described, your app will not be approved.
To submit your app:
- On the app page, go to App Review → Requests and click Request Permissions or Features.
- For each of instagram_basic, instagram_manage_messages, and Human Agent parameters, click Request Advanced Access in the Action column.
- Go to the Requests tab and click Edit for the draft request with these parameters.
- Fill in the request form according to the instruction. While filling it in, you must include screen recordings that show how to test any functionality that relies on that permission or feature.
- After you complete the request, click Submit for Review.
Wait for Facebook’s decision on your app. If your request is approved, you can start using the Instagram integration.
Publish your Page and app
After your chatbot is approved, you need to publish your Page and app.
To publish your Page, in the Manage Page menu go to Settings and choose Page published in the Page Visibility field.
After you publish your app, all the clients that find your page and click the Send message button will be able to talk to the bot.