Overview
The Direct Message: Create operation of the ETTwitter n8n node allows you to send a direct message (DM) to a specified Twitter user. This is useful for automating private communications, such as sending notifications, alerts, or personalized messages directly to users on Twitter. For example, you could use this node to automatically send a welcome message to new followers, deliver support responses, or share confidential information that should not be posted publicly.
Properties
| Name | Type | Meaning |
|---|---|---|
| User ID | String | The ID of the Twitter user who should receive the direct message. |
| Text | String | The content of your Direct Message. Must be URL-encoded if necessary. Maximum length is 10,000 characters. |
| Additional Fields | Object | Optional collection of extra parameters. Currently supports: |
| - Attachment (String): Name of the binary property containing data to be added as an attachment to the DM. |
Output
- The output is a JSON object representing the created direct message event as returned by the Twitter API.
- Typical fields include:
type: Always"message_create".id: Unique identifier for the DM event.created_timestamp: When the DM was sent.message_create: Contains details about the recipient and message content.target.recipient_id: The user ID of the recipient.message_data.text: The text of the message.message_data.attachment(optional): If an attachment was included, contains media information.
Example Output:
{
"type": "message_create",
"id": "1234567890",
"created_timestamp": "1680000000000",
"message_create": {
"target": { "recipient_id": "987654321" },
"message_data": {
"text": "Hello from n8n!",
"attachment": {
"type": "media",
"media": { "id": "1122334455" }
}
}
}
}
- If an error occurs and "Continue On Fail" is enabled, the output will contain an
errorfield with the error message.
Dependencies
- Twitter API: Requires valid Twitter credentials (OAuth1) configured in n8n under the name
twitterOAuth1Api. - Binary Attachments: If using attachments, the referenced binary property must exist in the input item.
Troubleshooting
Common Issues:
- Invalid User ID: If the provided User ID does not exist or cannot receive DMs, the request will fail.
- Text Too Long: Exceeding the 10,000 character limit will result in an error.
- Missing Attachment Data: If the specified binary property for the attachment does not exist, the node will throw an error.
- Authentication Errors: Invalid or missing Twitter credentials will prevent the node from sending messages.
Error Messages:
"User not found": Check the User ID for typos or ensure the user exists."You cannot send messages to this user": The recipient may have DMs disabled or privacy settings preventing messages."Attachment not found": Ensure the binary property name matches an existing binary input."Authentication failed": Verify your Twitter OAuth credentials in n8n.