Instagram Business

Instagram Business API with real Meta API calls + App Secret

Overview

This node integrates with the Instagram Business API to send direct messages to Instagram users. It allows sending real-time messages using the official Meta API, making it useful for automating customer support, marketing outreach, or engagement campaigns on Instagram.

A practical example is automatically replying to user inquiries by sending personalized messages based on triggers in your workflow, such as new leads or support tickets.

Properties

Name Meaning
User ID Instagram User ID (IGID) of the recipient to whom the message will be sent. Example: "17841400000000000".
Message Text The text content of the direct message to send. Example: "Hello! Thanks for your message."

Output

The node outputs a JSON object containing the result of the send message operation. Key fields include:

  • success: Boolean indicating if the message was sent successfully.
  • operation: The operation performed, here always "sendMessage".
  • userId: The Instagram User ID the message was sent to.
  • messageText: The text content of the sent message.
  • messageId: The unique identifier of the sent message returned by the API.
  • sentAt: Timestamp when the message was sent.
  • appSecretProofUsed: A truncated string representing the app secret proof used for authentication.
  • timestamp: Execution timestamp.
  • nodeVersion: Version of the node implementation.

If an error occurs, the output JSON contains:

  • error: Error message describing what went wrong.
  • success: false
  • operation: "sendMessage"
  • timestamp: Execution timestamp

The node does not output binary data.

Dependencies

  • Requires an API key credential providing an access token and an app secret for authenticating with the Meta Instagram Graph API.
  • Requires the environment variable N8N_META_UUID to be set with a valid UUID string (minimum length 8 characters).
  • Uses the crypto module to generate an HMAC SHA256 app secret proof for secure API calls.
  • Makes HTTP requests to the Meta Graph API endpoints (https://graph.facebook.com/v18.0/me/messages).

Troubleshooting

  • Missing Environment Variable: If N8N_META_UUID is not set or too short, the node throws an error instructing to define this variable.
  • Missing Credentials: Errors occur if the access token or app secret are missing from credentials.
  • API Errors: If the API returns an error (e.g., invalid token, permission issues), the node throws an error with the API's error message.
  • Common Error Messages:
    • "Access token is required": Ensure the API key credential includes a valid access token.
    • "App Secret is required for server-side API calls": Provide the app secret in the credential.
    • "API Error: <message>": Check the API error message for details; often related to permissions or invalid parameters.
  • To resolve errors, verify that the API credentials are correct, the environment variable is set, and the user ID and message text inputs are valid.

Links and References

Discussion