Actions7
Overview
This node allows you to send a direct message (DM) on Instagram to a user by specifying their username. It leverages the Instagram Private API to perform this action, handling authentication and session management automatically. This is useful for automating outreach, notifications, or customer engagement workflows where you need to programmatically send messages to Instagram users.
Practical examples:
- Sending automated welcome messages to new followers.
- Notifying users about updates, promotions, or support responses via Instagram DM.
- Integrating Instagram messaging into broader marketing or support automation flows.
Properties
| Display Name | Type | Description |
|---|---|---|
| Username | String | Username to send message to |
| Message | String | Message to send |
- Username: The Instagram handle of the recipient. Required for this operation.
- Message: The text content you want to send as a direct message. Required for this operation.
Output
The output is a JSON object with the following structure:
{
"success": true,
"username": "recipient_username",
"userId": "recipient_user_id",
"message": "Your message text",
"sessionData": { /* ... */ }
}
- success: Indicates if the message was sent successfully (
trueorfalse). - username: The username of the recipient.
- userId: The internal Instagram user ID of the recipient.
- message: The message that was sent.
- sessionData: Session information that 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, password). Optionally, session data can be provided to avoid repeated logins.
- n8n Credential Configuration: Requires a credential named
instagramPrivateApi. - External Libraries: Uses the
instagram-private-apinpm package. - File System Access: Stores session data in the user's home directory under
.n8n/instagram-sessions.
Troubleshooting
Common Issues:
- Invalid Credentials: If your username or password is incorrect, authentication will fail.
- Session Expiry: If the session data becomes invalid, the node will attempt to re-authenticate.
- User Not Found: If the specified username does not exist, you'll receive an error indicating the user was not found.
- Messaging Restrictions: Some users may have privacy settings that prevent receiving DMs from your account.
Common Error Messages:
"Username is required": Ensure you provide a value for the Username property."Message is required": Ensure you provide a value for the Message property."User \"<username>\" not found": Double-check the spelling of the username."Login required. Please authenticate with Instagram first.": Your session has expired or is invalid; update your credentials or session data."Checkpoint required. Please verify your account.": Instagram requires additional verification (e.g., due to suspicious login activity).
How to resolve:
- Double-check your input values.
- Update your Instagram credentials or session data if prompted.
- If you encounter checkpoint errors, log in to Instagram manually and complete any required verification steps.