Tutorial: How to Create a Custom Instagram Chatbot

Getting Started Aug 8, 2021

A few years ago, I created an Instagram page for my dog: @randoreo. Two years have gone past and Oreo now has around 5k followers. Oddly enough, Oreo receives quite a lot of DMs on Instagram of people who actually send messages to my dog, but unfortunately, my dog's paws are way too big to type on keyboards. So I thought I'd make a chatbot that would reply instead of Oreo so every message sent to Oreo on Instagram gets an appropriate response.

In this article I will walk you through creating a CSML chatbot and connecting it with your Instagram account.

The Chatbot

Let's create a simple chatbot on CSML Studio that answers with as many "Whoof" as there are words in the user's input. So the chatbot would answer "Whoof whoof whoof" to "How are you?".

Of course you can create the chatbot experience that makes the most sense for you. Check out some cool CSML chatbot templates over here.

start:
  remember whoofs = ["whoof", "whoaf", "whoohoof", "whuf"]
  say "Whoof?"
  goto whoofements

whoofements:
  hold
  do r = ""
  foreach (item) in event.split(" ") {
    do r = "{{r}}{{OneOf(whoofs)}} "
  }
  say "{{r}}"
  goto whoofements

Connecting your Chatbot to Instagram

Instagram Account Prerequisites

At the time of writing this article, Instagram is limiting this feature to accounts that have between 1,000 and 100,000 followers. For testing purposes however, you can create a brand new Instagram account that has a username starting with test_, like let's say test_mycompany. If you want to know more about these prerequisites, head over to this page.

Step 1: Prepare the Instagram Account

Before it can be connected to a chatbot your Instagram account needs to be set up in a specific way. Let's walk through this.

  1. Business account: your Instagram account needs to be a Business account. In order switch to Business account, you need to open Instagram, go to settings, click on Switch to professional account, then on Business, and fill in your company infos to finish the process.
    Make sure that your account is set to Business account, not Creator account. If your Instagram account is already setup as a Creator account, you can change this under Settings > Account > Switch to Business Account. Please note that this can only be done in the mobile application, not on desktop! More informations over here.
  2. Your Instagram account also must be open to direct messages from everybody. If you are unsure of how your account is setup or want to change settings, open your Instagram menu on your smartphone, then go to  Settings > Privacy > Messages and select Allow Access to Messages from everybody. Again, you can read the official documentation over there.

The second step of this process is to link your Instagram account with a dedicated Facebook business page. As you know Instagram belongs to Facebook, and Instagram's chatbot features are very close to Messenger chatbot features; the configuration process certainly reflects that.

First, create a new Facebook page (or use an existing one if you want). You can give any name to this page: in my case I gave it the same name as the Instagram account username: Randoreo. Make sure it is published!

Once the page is created, you'll need to associate it to your Instagram account. In order to do so, follow the guide on this page.

Step 3: Connect your CSML Chatbot to Instagram

Now that your chatbot is created and your Instagram account is ready and linked to your Facebook page, you can finally deploy your chatbot on Instagram!

Go to CSML Studio, select your chatbot, and click on Channels in the left sidebar, then click on Instagram to create a new Instagram channel.

First, you need click on Continue with Facebook and connect to your account.

In the Facebook login flow that follows, you must select the Instagram account and its associated Facebook page.

Warning: if you already connected CSML Studio to your Facebook account in the past, you'll need to make sure that you add the correct page to the list of available pages on CSML Studio. To do so, click on Edit settings as you login to Facebook, in order to edit the list of available Instagram accounts and Facebook pages.
List of available Instagram Business account
List of available Facebook pages

Before validating, make sure you give CSML Studio access to the list of resources.

You should now be able to see the list of Facebook pages that CSML Studio has access to.

Simply select the page associated to your Instagram Business account, and voilà: your chatbot is now deployed on Instagram!

Using a second account, you can now chat with your chatbot! Try talking to @randoreo:

Using this short Instagram Chatbot tutorial and CSML Studio, it's very easy to create powerful chatbots for Instagram. Instagram is one of the most used social apps and if you use Instagram for your business, you should definitely consider automating your DMs with a custom chatbot!

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.