Instagram Private API icon

Instagram Private API

Interact with Instagram using the private API

Overview

This node allows you to send a direct message (DM) on Instagram to a user by specifying their User ID. It leverages the Instagram Private API to perform this action, handling authentication and session management automatically. This is particularly useful for automating outreach, notifications, or customer engagement workflows where you know the recipient's Instagram User ID.

Example scenarios:

  • Sending automated welcome messages to new followers whose User IDs are known.
  • Notifying specific users about updates, offers, or alerts via Instagram DM as part of a marketing or support workflow.

Properties

Display Name Type Description
User ID String User ID to send message to
Message String Message to send
  • User ID: The unique identifier of the Instagram user who will receive the DM. This must be provided for the operation to succeed.
  • Message: The text content of the DM to be sent. This field is required.

Output

The output is a JSON object with the following structure:

{
  "success": true,
  "userId": "<provided User ID>",
  "message": "<sent message>",
  "sessionData": { /* Instagram session data object */ }
}
  • success: Boolean indicating if the message was sent successfully.
  • userId: The User ID to which the message was sent.
  • message: The content of the message that was sent.
  • sessionData: An object containing the current Instagram session data, which can be used to maintain authentication between runs.

If an error occurs, the output may look like:

{
  "success": false,
  "error": "<error message>"
}

Dependencies

  • Instagram Account Credentials: You must provide valid Instagram credentials (username and password) via n8n credentials named instagramPrivateApi.
  • Session Data (optional): For persistent sessions, session data can be stored and reused to avoid frequent logins.
  • External Libraries: Uses the instagram-private-api npm package.
  • File System Access: The node stores session files in the user's home directory under .n8n/instagram-sessions.

Troubleshooting

Common Issues:

  • Missing Required Fields: If either "User ID" or "Message" is not provided, the node will throw an error stating the missing field.
  • Authentication Errors:
    • "Login required. Please authenticate with Instagram first."
      Ensure your credentials are correct and up-to-date.
    • "Checkpoint required. Please verify your account."
      Instagram may require additional verification (e.g., email or phone confirmation). Complete these steps manually in the Instagram app.
  • User Not Found:
    • "User with ID \"<id>\" not found or cannot be messaged."
      Double-check the User ID and ensure the user exists and can receive DMs.
  • API/Internal Server Errors:
    The node attempts multiple fallback methods if Instagram returns a 500 Internal Server Error, but repeated failures may indicate temporary issues with Instagram's backend.

How to resolve:

  • Verify all input fields are filled correctly.
  • Check your Instagram credentials and session data.
  • If encountering checkpoint errors, log into Instagram manually to complete any required verifications.
  • Ensure the target user allows DMs from your account.

Links and References

Discussion