Instagram Messaging

Our business messaging API supports sending and receiving messages on Instagram Messaging.

Being able to send Instagram messages requires requesting access via the Channels portal. Without onboarding with Instagram via the portal, you can not make use of this part of the API.

Fact sheet

FeatureSupportRemarks
delivery notificationyesOccurs when your message is delivered to the Instagram platform. Delivery notifications are sent to the status report webhooks.
text messagesyesThe maximum length of a Instagram message is 1.000 characters and it must be UTF-8 encoded.
mediayesMedia name attribute should end in the proper file extension. Only one media file is allowed per message; when sending multiple files, each file will be sent in its own Instagram message. When the linked media doesn't exist/can't be found, the message will not be sent at all. The provided text message is sent in a separate Instagram message.
media: imagesyesMaximum file size for an uploaded image is 8 MB. Supported formats:Β png, jpeg, gif.
media: gifyes
media: audioyesMaximum file size for an uploaded audio file is 25 MB. Supported formats: acc, m4a, wav, mp4.
media: videoyesMaximum file size for an uploaded video file is 25 MB. Supported formats: mp4, ogg, avi, mov, webm.
reply suggestionsyesMaximum label length: 20 characters.
rich cardyesSupport for generic template.
rich carouselyesSupport for generic template. Maximum of 10 templates supported.
message tagsyesAllows messaging outside the standard messaging window of 24 hours.
handover protocolyesAllows handover to the Instagram Inbox for live agents.
marketing messages: optin requestsyesSupport for sending marketing messages optin requests.
marketing messages: notificationsyesSupport for sending all message types as marketing message.

Prerequisites

To be able to onboard, you need to set-up the following:

Link your Instagram account to CM.com

Onboarding is done via our Channels portal. On our portal, you will be presented with a Facebook login pop up where you need to login with your Facebook account that is linked to your Instagram Business account.

In this pop up you will need to authorize our Facebook app, called CM.com Business Messaging to send and receive Instagram messages on behalf of your Instagram account.

This app requires the following permissions to work correctly:

  • "Access profile and posts from the Instagram account connected to your Page"
  • "Manage and access Page conversations in Messenger"
  • "Show a list of the Pages you manage"
  • "Manage and access messages for the Instagram account connected to your Page"
  • "Manage accounts, settings and webhooks for a Page"

If you choose to de-select these permissions in the Facebook pop up, we will not be able to complete the onboarding.
It is allowed to have multiple Instagram accounts under one CM.com account.

Business rules

Sending Instagram messages using the CM.com Business Messaging API also requires you to adhere to the Instagram Policy & Guidelines.

Please note that you must comply to Instagram's Technical Requirements. Specifically for incoming messages:

  • When you make use of media messages, ensure you only store the privacy aware CDN URL in your system and use this link to render the media made accessible. See also Media Message.
  • Ensure you process Story Reply messages. A Story Reply message is sent to you when a user replies to your Instagram Story. See also Story Reply.
  • Ensure you process Message Delete events. Message Delete events occur when a message in Instagram is deleted by a user. See also Message Delete.
  • Ensure you process Instagram Story Mention events. Story Mention events occur when a user mentions your business in their Story. See also Story Mention.
  • Ensure your messaging experience has an escalation path to a human agent. If you have a custom inbox solution, you can handle the escalation yourself. If not, you can use the Handover to Instagram Inbox. See also Instagram Handover Protocol.

Considerations

Note that in case of Instagram, the Instagram account that is used for sending messages is also still available in the regular Instagram app, from the Instagram website and from other 3rd party Instagram apps. Our API only has permissions to send messages on behalf of the Instagram account, it's not exclusively in control of that Instagram account.

This means that it will be possible to send messages using Instagram as well as using our API, and that might lead to situations where the API will relay replies to messages you sent via the Instagram app or website.

In those cases it will seem like messages are missing from a conversation when you use both ways of communicating with your end-users.

Our recommendation is to use the API exclusively for these Instagram accounts, and not switch between the Instagram app or website and the API, because the API won't "know" about the messages you sent using the app or website, but it will receive the replies to those messages.

The only way to have a Instagram conversation with end-users is when the end-user starts the conversation by sending you an initial message.

Instagram has rate limits in place; the hourly rate limit is equal to 200 * the number of people the customer can message via Instagram. This limit is high enough for most use cases. So if you have 1 conversation with 1 customer you can sent maximum 200 messages back to this customer. If there are 2 conversations with 2 customer you can sent maximum 400 messages back to these customers.

If you choose to revoke any of the permissions given during the onboarding process on Facebooks side, we might no longer be able to deliver messages.

Sending messages

Unlike other channels, Instagram Messaging does not use telephone numbers as identifiers for sender (from) and recipient (to.number), instead it uses a so called "Instagram Scoped User ID (IGSID)" for the recipient and a "Instagram Account ID" for the sender. A person is assigned a unique IGSID for each Instagram Business account they start a conversation with.

Your Instagram Account ID is visible in the CM.com platform under channels...Instagram.

Message Tags

Message tags enable sending important and personally relevant 1:1 updates to users outside the standard messaging window of 24 hours. This enables greater flexibility in how you interact with people, as well as the types of experiences you can build for Instagram Messaging. They may not be used to send promotional content (e.g. deals, offers, coupons, discounts, etc.). Use of tags outside of the approved use cases may result in restrictions on the Instagram Account to send messages. See the Messenger Platform and IG Messaging API Policy Overview for details.

The following message tags are supported:

TagDescription
HUMAN_AGENTAllows human agents to respond to user inquiries. Messages can be sent within 7 days after a user message.
NOTIFICATION_MESSAGEAllows to send all message types as a marketing message, needs to be combined with a notification_token as recipient.

Media

Media typeSupported formatsMimetypeSupported size maximum
Audioacc, m4a, wav, mp4audio/acc, audio/m4a, audio/wav, audio/mp425MB
Imagepng, jpeg, gifimage/png, image/jpeg, image/gif8MB
Videomp4, ogg, avi, mov, webmvideo/mp4, video/ogg, video/avi, video/mov, video/webm25MB

Display order

If you send a message including both an image and some text, Instagram will display these as separate messages; typically the text will be the first message.

See the Instagram message with text and image example.

Quick reply

Quick replies provide a way to present a set of buttons in-conversation for users to reply with. A maximum of 13 quick replies are supported and each quick reply allows up to 20 characters before being truncated. Quick replies only support plain text. Note: quick replies are only visible in the Instagram app, not via web browser.

The following restrictions apply for a quick reply:

FieldRequiredRemarks
labelYesMaximum length is 20 characters.
postbackdataYesMaximum length is 1000 characters.

More info can be found in the rich content description.

Rich card

Rich cards, called Generic Templates in Instagram Messenger, offer a way for you to offer a richer in-conversation experience than standard text messages by integrating buttons, images and more alongside text in a single message. Rich cards can be used for many purposes, such as displaying product information or asking the message recipient to choose from a pre-determined set of options.

Note: this is supported only for the Instagram App.

🚧

Note

When using a carousel (2 to 10 generic templates), put the cards containing a media image and at least a button first and/or second, as the behavior and sizing of the rest of the cards is affected by them.

A simple structured message that must include a title and must include at least one of the following: a subtitle, an image and/or up to three buttons.

This template will be used if fields are given that are not covered by other Instagram templates.

The following restrictions apply for a generic template:

FieldSupportRequiredRemarks
cardsYesYes (If header not defined)Maximum 10 allowed per message. At least one property must be set in addition to header.
headerYesYes (If cards not defined)Displayed as the title. Maximum length is 80 characters.
textYesNoDisplayed as the subtitle. Maximum length is 80 characters.
mediaUriYesNoThe URL of the image to display.
suggestionsYesNoMaximum of 3 buttons per card.

Marketing Messages

πŸ“˜

Before using Instagram Marketing Messages

Please note that it is not possible to set up Instagram Marketing Messages yourself, for this you need the help of our support department. If you are interested in this position, please contact your account manager. If you are not yet a customer, please contact our support department.

With Marketing Messages you can send (recurring) notifications on a topic, a user has opted-in to. During the 24-hour messaging window, you can send users this notification opt-in request for a certain frequency, either on a daily, a weekly, or a monthly basis. Users can opt-in to receive Marketing Messages any time after this opt-in request is sent. Once a user opts-in, you are allowed to send Marketing Messages related to the topic they opted-in to for a set frequency.

Best practices

  • Your opt-in request, including the title and image, encompasses the types of Marketing Message users can expect to receive, such as order updates, product recommendations, or certain offers.
  • When sending more than one opt-in request to a user, each opt-in request should clearly state the different, specific types of Marketing Message the user can expect to receive.
  • You must not use Marketing Messages, including opt-in requests, to spam users. This includes sending duplicate opt-in requests at high frequencies to the same users.

Users can provide feedback on your messaging experience, including blocking your messaging, which may result in restrictions on your use of Marketing Messages. You should regularly review your opt-in requests and Marketing Messages to see if they meet the best practices above.

Limitations

  • You can only send one opt in request to a person per week for the same, specific topic. This applies even if the opt in request is for a different frequency, for example, an opt in request for a weekly notification and an opt in for a monthly notification, on the same topic.
  • You may only send a request for a user to opt-in to Marketing Messages within the standard 24 hour messaging window. A user’s action of opting-in to Marketing Messages does not open the 24 hour messaging window.
  • Do not send duplicate opt-in requests to users, which is defined as having the same title and image_url.
  • You can only see if a person has opted in to receiving Marketing Messages.
  • If a person has chosen to stop receiving Marketing Messages, your notifications will no longer be delivered to that person and you will receive an error.
  • A person can block, mute, or report your messaging.

Sending Marketing Messages Opt-In Requests

🚧

This is currently only supported for the Instagram Mobile App. (Not clickable on IG web)

Before sending Marketing Messages, users must opt-in via an opt-in request. You must not send more than one opt-in request to a user per week on the same, specific topic. This applies even if the opt-in request is for a different frequency on the same topic. If you attempt to send an opt-in request to a user for the same topic in less than a week, the request will be blocked and you will receive an error message. In addition, there must be an open 24 hour messaging window before you can send an opt-in request to the user. Users can opt-in to receive Marketing Messages for multiple topics in the same thread. When a user chooses to opt-in on your Marketing Message a opt-in event will be triggered, see incoming events for more information on Instagram Marketing Messages events.

You can send an opt-in request as a single suggestion. The following restrictions apply for an opt-in message:

FieldRequiredRemarks
actionYesThe action field is required and always needs to have the value "optin" to send the message as a opt-in message.
postbackdataYesYour opt-in reference.
labelYesDisplayed as the title. Maximum lenght is 65 characters.
mediaUriNoThe URL of the image to display in the opt-in request.
optinYesSee table below for opt-in details.

The following fields can be included as part of opt-in:

FieldRequiredRemarks
frequencyYesDAILY, WEEKLY or MONTHLY
reoptinYesTrue or False. When value is True, an automatic reoptin is sent to end-user when subscription expires.
timezoneYesDefault value is UTC. List of available time zones

For a example opt-in request see.

Instagram Marketing Message Opt-In Request

Marketing Message opt-in request example

Sending Marketing Messages Notifications

After a user opt-in, depending on the frequency of the Marketing Message, this is how often notifications can be sent to the user:

Daily Marketing MessagesWeekly Marketing MessagesMonthly Marketing Messages
Once every calendar day which starts from 12:00am until 11:59pm in the time zone set by you.Once every calendar week which starts from Monday at 12:00am until Sunday at 11:59pm in the time zone set by you.Once every calendar month which starts from the 1st at 12:00am until the last day of the month at 11:59pm in the time zone set by you.

For example, if the user opted-into receiving weekly Marketing Messages, and you have set the time zone to America/New_York, this is a possible schedule of Marketing Messages sent by you:

  1. First Marketing Message sent on Monday @ 5:00 PM EDT
  2. Next Marketing Message sent on Tuesday the following week @ 9:00 AM EDT

🚧

Important

A Marketing Messages message token is generated per opt-in (per user) which can then be used to send Marketing Messages. This means that instead of the users PSID you need to use the specific notification token received when the user opted-into your opt-in request to send Marketing Messages to this user.

If you sent two opt-in requests to your user, for daily and weekly, two separate notification message tokens are generated if the user opted-in to both daily and weekly Marketing Messages. If the user opted-in to daily, weekly, and monthly Marketing Messages, then three separate notification message tokens will be generated.

πŸ“˜

The NOTIFICATION_TAG

You can sent any type of Instagram message as a Marketing Message (except a opt-in request) as long as you use the notification token linked to the user as the recipient in combination with the "NOTIFICATION_MESSAGE" tag.

For a example opt-in request see.

Handover protocol

For Instagram Messaging, experiences must have an escalation path that allows end-users to speak to a human agent instead of a bot.
If you have a custom inbox solution, you can handle the human agent escalation by yourself by switching between a bot and live agents in your inbox solution.

If you don't have a custom inbox solution, we provide support to escalate to the Instagram inbox of your Instagram account instead by following the steps below.

Configure your Facebook page

In order to allow CM.com to perform a handover to your Instagram inbox, you need to update the settings of your Facebook page that is linked with your Instagram account after you have successfully onboarded in the CM.com platform.

In your Facebook page settings, go to Advanced messaging and browse to Handover protocol.

Click on the Configure button and select CM.com Business Messaging as the primary receiver for the handover protocol.

Handover to Instagram inbox

To provide the end-user to speak with a human agent via the Instagram inbox, you must send a quick reply with HUMAN_AGENT as postback data.
If the end-user then selects this quick reply, the handover event will be triggered by CM.com, changing the conversation from the app to the message inbox in Instagram.

After the handover event has been triggered, CM.com has no control of the conversation for 24 hours.
During this timeframe, a human agent has to escalate the conversation with the end-user via your Instagram account. These messages will not be tracked by CM.com during the 24 hour timeframe until it has expired.

If your human agent is done with the conversation or want CM.com to take control again, sending a message via the Business Messaging API will cancel the handover protocol. This will make CM.com take control again of the conversation with the end-user.

Input matrix

You can use the following matrix to check what type of message will be sent with the included inputs.

TextMediaSuggestionsHeaderOutput
xxxxNot supported
√xxxText message
√√xxText and Media messages
xxx√Generic template with just a title
√xx√Generic template with a title and a subtitle
√√x√Generic template with a title, a subtitle and a media image.
√x√√Generic template with a title, a subtitle and up to 3 buttons.
x√x√Generic template with a title and a media image.
x√√√Generic template with a title, a media image and up to 3 buttons.
xx√√Generic template with a title and up to 3 buttons.
√√√√Generic template with a title, a subtitle, a media image and up to 3 buttons.

Receiving messages / Inbound flow

Since Instagram Messaging is used for 2-way communication (chat) it is important to also implement an Inbound flow. You can find more information about how to do this using our API documentation of the incoming messages. Note that for Instagram you need to set up your webhook API in the Channels app, not in the Gateway app.

Examples

An explanation on how to send rich content messages in general can be found in the rich content description.

Direct message with plain text content

The example below will send a simple text-only Instagram message.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "allowedChannels": ["Instagram"],
                "body": {
                    "type": "auto",
                    "content": "CM.com - Be part of it."
                }
            }
        ]
    }
}

Direct message with text and image

In the example below we send a simple rich content message that contains both text and an image that Instagram will display as two separate messages.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "allowedChannels": ["Instagram"],
                "body": {
                    "type": "auto",
                    "content": "Fallback Text"
                },
                "richContent": {
                    "conversation": [
                        {
                            "text": "CM.com - Be part of it.",
                            "media": {
                                "mediaName": "cm-tablet.jpg",
                                "mediaUri": "https://www.cm.com/cdn/web/blog/featured/cm-tablet.jpg",
                                "mimeType": "image/jpeg"
                            }
                        }
                    ]
                }
            }
        ]
    }
}

Direct message with quick reply suggestions

In the example below we send a rich content message that contains a text and some reply suggestions.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "text": "Hi, what can I do for you?",
                            "suggestions": [
                                {
                                    "action": "Reply",
                                    "label": "Call me",
                                    "postbackdata": "CALL"
                                },
                                {
                                    "action": "Reply",
                                    "label": "Email me",
                                    "postbackdata": "EMAIL"
                                },
                                {
                                    "action": "Reply",
                                    "label": "Send me an sms",
                                    "postbackdata": "SMS"
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}

Direct message with quick reply suggestion for handover protocol

In the example below we send a rich content message that contains a text and some reply suggestions. One of the suggestions with postback data HUMAN_AGENT will trigger the handover protocol.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "text": "Hi, what can I do for you?",
                            "suggestions": [
                                {
                                    "action": "Reply",
                                    "label": "Ask a question",
                                    "postbackdata": "QUESTION"
                                },
                                {
                                    "action": "Reply",
                                    "label": "Talk to live agent",
                                    "postbackdata": "HUMAN_AGENT"
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}

Direct message with message tag

In the example below we send a simple text message with a message tag "HUMAN_AGENT" applied. This tag allows a human agent to respond to a user's inquiry outside of the standard 24 hour messaging window, up to 7 days after the user's last message.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "type": "auto",
                    "content": "Fallback Text"
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "text": "Dear customer, we have an update regarding your question",
                            "tag": "HUMAN_AGENT"
                        }
                    ]
                }
            }
        ]
    }
}

A single Rich Card with a title, a subtitle, a media image and two suggestions.

In the example below we send a rich content message that contains a rich card. The rich card is composed of a title, a subtitle, a media image and two suggestions. One of the suggestions will open an external url, while the other suggestion will start a handover protocol based upon it's postback data HUMAN_AGENT.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "header": "We are CM.com!",
                            "text": "Visit our website or start a chat with one of our employee's!",
                            "media": {
                                "mediaUri": "https://www.cm.com/cdn/web/blog/featured/cm-tablet.jpg"
                            },
                            "suggestions": [
                                {
                                    "action": "OpenUrl",
                                    "label": "Visit our website!",
                                    "url": "https://cm.com"
                                },
                                {
                                    "action": "Reply",
                                    "label": "I want to chat!",
                                    "postbackdata": "HUMAN_AGENT"
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}

A carousel of Rich Cards with different compositions of a title, a subtitle, a media image and multiple suggestions.

In the example below we send a rich content message that contains a carousel of rich cards. The rich cards have multiple different compositions in which they are shown to the end user.

Three possible different compositions are:

  1. A title, a subtitle, a media image and two suggestions.
  2. A title and a media image.
  3. A title, a subtitle and three suggestions.

It's possible to mix different elements with each other.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "carousel": {
                                "cards": [
                                    {
                                        "header": "We are CM.com!",
                                        "text": "Visit our website or start a chat with one of our employee's!",
                                        "media": {
                                            "mediaUri": "https://www.cm.com/cdn/web/blog/featured/cm-tablet.jpg"
                                        },
                                        "suggestions": [
                                            {
                                                "action": "OpenUrl",
                                                "label": "Visit our website!",
                                                "url": "https://cm.com"
                                            },
                                            {
                                                "action": "Reply",
                                                "label": "I want to chat!",
                                                "postbackdata": "HUMAN_AGENT"
                                            }
                                        ]
                                    },
                                    {
                                        "header": "Our logo!",
                                        "media": {
                                            "mediaUri": "https://www.cm.com/cdn/web/blog/featured/cm-tablet.jpg"
                                        }
                                    },
                                    {
                                        "header": "Conversational Channels",
                                        "text": "Here's a selection of some of the channels we support!",
                                        "suggestions": [
                                            {
                                                "action": "OpenUrl",
                                                "label": "WhatsApp!",
                                                "url": "https://www.cm.com/whatsapp/"
                                            },
                                            {
                                                "action": "OpenUrl",
                                                "label": "Instagram Messaging!",
                                                "url": "https://www.cm.com/instagram-messaging"
                                            },
                                            {
                                                "action": "OpenUrl",
                                                "label": "RCS!",
                                                "url": "https://www.cm.com/rcs/"
                                            }  
                                        ]
                                    }
                                ]
                            }                                                      
                        }
                    ]
                }
            }
        ]
    }
}

Marketing Messages Opt-In Request

In the example below we send a Marketing Message opt-in request that gives the recipient the option to opt-in on your notifications.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "Recipients IGSID"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                "richContent": {
                    "conversation": [
                        {
                            "suggestions": [
                                {
                                    "action": "optin",
                                    "postbackdata": "OPT_IN",
                                    "label": "Receive daily product updates",
                                    "media": {
                                        "mediaName": "cm-tablet.jpg",
                                        "mediaUri": "https://www.cm.com/cdn/web/blog/featured/cm-tablet.jpg",
                                        "mimeType": "image/jpeg"
                                    },
                                    "optin": {
                                        "frequency": "DAILY",
                                        "reoptin": "True",
                                        "timezone": "Europe/Amsterdam"
                                    }
                                }
                            ]
                        }
                    ]
                }
            }
        ]
    }
}

Sending Marketing Messages

In the example below we send a text message as a Marketing Message. Reminder: Every message type can be used as a Marketing Message as long as you combine the notification token with the "NOTIFICATION_MESSAGE" tag.

{
    "messages": {
        "authentication": {
            "producttoken": "Your product token"
        },
        "msg": [
            {
                "from": "Your Instagram account ID",
                "to": [
                    {
                        "number": "The notification token of the user"
                    }
                ],
                "body": {
                    "content": ""
                },
                "allowedChannels": ["Instagram"],
                 "richContent": {
                    "conversation": [
                        {
                            "text": "CM.com - Be part of it.",
                            "tag": "NOTIFICATION_MESSAGE"
                        }
                    ]
                }
            }
        ]
    }
}