Important differences#
Beta version
The functionality is in beta. Features may change and may also work unstably.
The Instagram integration is built on the same contract as the other GREEN-API integrations: the same method addresses, the same field names, the same webhooks. At the same time, Instagram has its own specifics: besides messaging, the platform provides additional features, and some features available in other messengers are not supported in it. Below are the main differences to take into account when developing an integration.
Table of contents#
- The way an instance is authorized
- Chat identifier
- Addressing by username
- Posts and comments
- The messenger type in a webhook
- What the API does not have
- Others
The way an instance is authorized#
There is no QR code authorization in Instagram. An instance is authorized in one of two ways:
- by the Login method - with the login and password of the account.
If Instagram requests a confirmation code, it is passed by the SendAuthorizationCode method; if Instagram waits for a confirmation on a device where the account is already open, the login is confirmed in the Instagram app;
- through the session of a browser where the account is already authorized - by the
green-api-connectorextension. The password is not passed in this case.
With the browser session authorization several methods are unavailable or limited - see the list.
Chat identifier#
The chat identifier (chatId) is a string value that consists of digits only:
- For a personal chat - it is the numeric identifier of the contact's account, for example
49547665464; - For a group chat - it is the numeric identifier of the thread, for example
340282366841710300949128174631143137232.
In Instagram, chat identifiers cannot be negative and do not contain the @c.us or @g.us suffixes. Such values are not used in API responses and webhooks. If an identifier in a wrong format is passed, the method returns a 400 error.
Sending messages by phone number is not supported in Instagram. To send a message, use the chat identifier (
chatId).
Addressing by username#
Instead of an identifier, the methods accept the contact's username - in the same chatId, with the @ prefix:
{
"chatId": "@green_api",
"message": "I use GREEN-API to send this message to you!"
}
The separate username field is accepted by the CheckAccount method only: the other methods do not accept it and answer 400 with the text 'username' is not allowed. The numeric identifier for a username is returned by the GetContactInfo or CheckAccount method.
More details are in the Chat identifier article.
Posts and comments#
Instagram is not only chats, that is why the API has sections that the other integrations do not have:
- Posts - publishing posts, Reels and carousels, editing and deleting a post, reading posts and profile feeds;
- Comments - getting comments and reply threads, sending comments, replying to them, adding likes and deleting comments.
Notifications arrive about new comments on your own posts. Comments on other users' posts can be obtained with the GetComments method on request.
The messenger type in a webhook#
To determine the type of the messenger a webhook came from, analyze the instanceData.typeInstance webhook property.
- For Instagram:
"typeInstance": "instagram" - For the MAX messenger:
"typeInstance": "v3" - For the WhatsApp messenger:
"typeInstance": "whatsapp" - For the Telegram messenger:
"typeInstance": "telegram"
You can also use the SetSettings method to receive webhooks at different webhookUrl values in order to separate the processing flows of webhooks from different messengers.
What the API does not have#
The methods of the GREEN-API contract that have no equivalent in Instagram are absent from the API:
- sending polls, a location and a profile card: such messages can be received - a poll, a location, a profile card;
- QR authorization and the instance cloud password;
- local contact names (adding, editing and deleting a contact);
The methods of the GREEN-API contract with limited features:
- of the group settings, Instagram Direct supports only adding participants without admin approval.
- Instagram Direct supports sending images, videos and voice messages. Sending documents is not supported.
Most of the API methods are available with any way of authorization, but on an instance with an imported browser session some of them are limited.
Others#
Some methods return a set of parameters specific to Instagram.
The full description of all methods and parameters can be found in the Instagram API documentation.