Receive direct messages on your Instagram accounts and answer them.
What you can do
- Receive the direct messages people send your Instagram professional accounts, in your inbox and as
message.receivedevents. - Answer them with text, quick replies, media, reactions or cards.
Before you start
An owner or admin connects the account in the dashboard, by signing in with Instagram or through a Facebook Page linked to it. An account connected to another workspace is refused.
Instagram allows a message only to someone who wrote to you:
- Within 24 hours of their last message, anything goes.
- After that, only a person signed in to your inbox may reply, until 7 days have passed. An API key cannot.
- Nobody who has not written can be messaged, so there are no Instagram campaigns.
Receive
Text, story replies, story mentions, shares, reactions, postbacks and read receipts land in your inbox on the instagram channel, and your webhook endpoints receive message.received.
- Each person who writes becomes a contact with no phone. Their Instagram-scoped id is their identity, and the
contactaddress of their thread. - A file they send is downloaded when it arrives, since Instagram's links expire, and served at a signed link the message holds.
Send
Reply to the person's Instagram-scoped id:
curl https://v3.ghala.io/v1/messages \
-H "Authorization: Bearer $GHALA_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: thread-880000000000001-reply-1" \
-d '{"channel": "instagram", "to": "880000000000001", "type": "text", "text": "Karibu"}'/v1/messagesSend messagemessages:send
tois one person's Instagram-scoped id. One recipient per send.fromis the account, by its id fromGET /v1/channels/instagramor its Instagram id. Leave it out when your workspace has one account.typeistext(1 to 1,000 bytes),quick_replies,image,video,audio,file,reactionorcards. Every limit is checked before anything goes to Instagram, and a refusal names the field.
The answer is 201 with {"status": "sent", "channel": "instagram", "messages": [...]}. You can also answer in the thread with Inbox and replies.
Each message is priced at your workspace's Instagram rate. A send Instagram refused is not charged.
Statuses
Instagram reports read when the person opens your message. See Message statuses.
Test mode
Instagram has no sandbox. A test key is refused with not_configured: "instagram has no sandbox; send with a live key".
When it fails
| Status | code | When |
|---|---|---|
400 | missing_field on from | your workspace has several accounts and from did not say which |
400 | invalid_value on to | more than one recipient |
400 | not_configured | a test key, or no Instagram rate is set for your workspace |
402 | insufficient_funds | your wallet cannot pay for the message |
409 | instagram_window_closed | outside Instagram's window, or the person has not written |
409 | instagram_account_disconnected | no connected account, or not the one in from |
502 | instagram_send_failed | Instagram did not take the message |