Description
The Instagram DM integration connects an Instagram Business account to Kommander so customer direct messages can become Kommander conversations. Inbound text DMs are received from Meta webhooks, normalized as site: "instagram" and provider: "instagram", routed through the assistant, and answered through the Instagram Messaging API.
This guide covers the production setup path for text-based Instagram Direct Messages. Advanced Graph API features such as media handling, templates, reactions, and commerce messaging are outside the current integration scope.
Prerequisites
- A Kommander organization with a trained assistant.
- A public HTTPS Kommander deployment URL.
- An Instagram Business or Creator account connected to a Facebook Page.
- A Meta developer app with Instagram messaging enabled.
- Access to the Meta Developer Dashboard for the app.
- A Meta verify token saved in Kommander.
- An Instagram access token that belongs to the connected business account.
- The Instagram Business Account ID used by the Messaging API.
- The App Secret of the Meta app, so Kommander can verify webhook signatures.
- Completed Meta App Review or Advanced Access for production users.
Meta Graph API Setup
- In Meta Business settings, confirm the Instagram account is professional and connected to the Facebook Page managed by the app.
- In the Meta Developer Dashboard, open the app that owns the Instagram connection.
- Add or enable the Instagram messaging product for the app.
- Generate a long-lived access token for the Page or system user that can manage the connected Instagram account.
- Copy the Instagram Business Account ID from Meta. This is the sender identity Kommander uses when it posts replies.
- In Kommander, open Integrations > Instagram DM.
- Paste the Instagram access token, Instagram Business Account ID and Meta App Secret (App settings > Basic > App Secret), then save the integration. Once the App Secret is saved, Kommander rejects webhook requests without a valid
X-Hub-Signature-256.
Use META_GRAPH_API_VERSION in server configuration when the deployment needs a specific Graph API version. Kommander falls back to v22.0 when the value is not set.
Permission Requirements
Meta controls Instagram DM access through product setup, account connection, and App Review. Before enabling production traffic, confirm these requirements in the Meta dashboard for the app and Graph API version you deploy.
| Requirement | Purpose |
|---|---|
| Instagram professional account | Instagram Messaging API requires a Business or Creator account. |
| Connected Facebook Page | Meta uses the Page connection to authorize messaging access for the Instagram account. |
instagram_manage_messages | Allows the app to receive and send Instagram messages. |
pages_manage_metadata | Allows webhook subscriptions and Page metadata access needed by Meta messaging products. |
pages_messaging or equivalent Meta messaging access | Required by some Meta app configurations for messaging products. Verify the exact permission set in the current dashboard. |
| App Review or Advanced Access | Required before messages from production users outside app roles can be handled. |
Keep the access token encrypted in Kommander and rotate it if an admin, contractor, or deployment environment loses access.
Webhook Configuration
- Copy the Instagram webhook callback URL from Kommander:
https://YOUR_DOMAIN/api/instagram/YOUR_ORGANIZATION_ID- Copy the Meta verify token shown in Kommander.
- In the Meta Developer Dashboard, open the app webhook settings for Instagram messaging.
- Add the callback URL from step 1 and paste the verify token from step 2.
- Save the subscription. During verification, Meta sends
hub.mode=subscribe,hub.verify_token, andhub.challenge; Kommander returns the challenge only when the verify token matches the organization. - Subscribe to Instagram message events for the connected Instagram account. In most setups this includes inbound message events; verify the exact event names shown by Meta for the app’s current Graph API version.
- Send a test DM from an Instagram account that is not the connected business account and confirm a Kommander conversation appears.
Instagram DM Ingress Diagram
The ingress path receives Meta webhook events, extracts only supported text messages, scopes the conversation to Instagram, and sends the assistant answer back through Graph API.
Message Handling Flow
Kommander stores Instagram conversations separately from WhatsApp conversations. Conversation lookup is scoped by organization ID, Instagram sender ID, site: "instagram", and provider: "instagram" so the same customer can message different channels without mixing thread history.
Supported Webhook Payload
Kommander expects Instagram DM text messages in Meta’s Messenger-style entry[].messaging[] payload shape.
{
"object": "instagram",
"entry": [
{
"id": "17841400000000000",
"time": 1717420440,
"messaging": [
{
"sender": { "id": "12345678901234567" },
"recipient": { "id": "17841400000000000" },
"timestamp": 1717420440000,
"message": {
"mid": "m_abc123",
"text": "Can I book from Instagram?"
}
}
]
}
]
}Only inbound text messages are handled. Kommander ignores echo messages, delivery receipts, read receipts, reactions, attachments, unsupported event shapes, and messages without text.
Reply Delivery
When the assistant or an operator replies, Kommander sends text through the Instagram Messaging API with the saved access token and Instagram Business Account ID.
POST https://graph.instagram.com/v22.0/{instagramBusinessAccountId}/messages
Authorization: Bearer INSTAGRAM_ACCESS_TOKEN
Content-Type: application/json{
"recipient": { "id": "12345678901234567" },
"message": { "text": "Yes, you can book directly from here." }
}Before delivery, Kommander formats assistant text for Instagram by removing unsupported markdown bold markers and converting markdown links into readable label: url text. The original answer remains in Kommander conversation history.
Configuration Reference
| Setting | Required | Where to configure | Notes |
|---|---|---|---|
| Instagram webhook URL | Yes | Kommander and Meta Developer Dashboard | Uses /api/instagram/YOUR_ORGANIZATION_ID and must be public HTTPS. |
| Meta verify token | Yes | Kommander and Meta Developer Dashboard | Must match exactly for webhook subscription verification. |
| Instagram access token | Yes | Kommander | Stored encrypted and used only for Instagram reply calls. |
| Instagram Business Account ID | Yes | Kommander | Used as the Graph API sender path segment. |
META_GRAPH_API_VERSION | Optional | Server environment | Falls back to v22.0 if unset. |
| App Review or Advanced Access | Production required | Meta Developer Dashboard | Required before handling messages from users outside app roles. |
Error Scenarios
| Scenario | What you see | How to fix |
|---|---|---|
| Webhook verification fails | Meta cannot save the callback URL or receives a non-200 response. | Confirm the URL includes the correct organization ID, uses HTTPS, and the verify token matches Kommander exactly. |
| Meta delivers events but no conversation appears | The webhook call succeeds, but Kommander reports no supported message or creates no thread. | Confirm the event contains entry[].messaging[].message.text and is not an echo, receipt, reaction, or attachment-only event. |
| Replies fail with an authorization error | The conversation is created, but Instagram does not receive an answer. | Rotate the token, confirm it belongs to the connected account, and verify required messaging permissions and App Review status. |
| Replies fail with an account ID error | Graph API rejects the /messages call. | Confirm the Instagram Business Account ID is copied from the same Meta app and account that issued the token. |
| Production users do not trigger messages | App-role users can test, but normal Instagram users cannot. | Complete Meta App Review or request Advanced Access for the required messaging permissions. |
| Conversations appear under the wrong channel | Messages are mixed with WhatsApp or another provider. | Confirm the ingress forwards site: "instagram" and provider: "instagram" and that the webhook URL points to /api/instagram/.... |
| Assistant responses are delayed | The DM appears, but the reply arrives late or not at all. | Check the Kommander assistant pipeline, reply endpoint logs, Graph API response body, and provider rate limits separately. |
Limitations
- V1 handles text messages only.
- Attachments, story mentions, reactions, read receipts, delivery receipts, templates, and commerce-specific events are ignored.
- Meta can change dashboard labels and subscription names between Graph API versions; verify the event names during each production rollout.
- Instagram DM support depends on the connected account type, token scope, App Review status, and current Meta platform rules.