Message
The Message component allows you to connect your automation workflows directly to Discord. You can use this node to send new messages, read existing ones, edit content, and manage interactions in Discord channels. It acts as a secure bridge between Nappai and your Discord account, handling all the necessary connections so you can focus on automating your communication tasks.
How it Works
This component communicates directly with the Discord API using your account credentials. When you place this component in your workflow, Nappai handles the secure authentication and data exchange. You simply provide the channel and message details, and the component executes the requested action.
If your workflow involves processing multiple items, the component can handle batches efficiently. It manages the connections, respects Discord’s rate limits, and returns the results so you can use that data in subsequent steps of your automation.
Connection & Credentials
This component requires a Discord API credential to function. You must set this up before you can use the node in your workflows.
- Go to the Credentials section in your Nappai panel.
- Create a new credential of type Discord API.
- Fill in the required fields: Public Key, Application ID, and Bot Token.
- You can find your Bot Token in the Discord Developer Portal under your application’s Bot section.
- In your workflow, select the saved credential in the Credential input field of this node.
Inputs
Mapping Mode
This component has a special mode called Mapping Mode. When you enable this mode using the toggle switch, an additional input called Mapping Data is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows, such as processing lists of messages or sending bulk notifications.
Input Fields
The following fields are available to configure this component:
- Channel ID: The unique identifier for the Discord channel where you want to interact.
- Message ID: The unique identifier for a specific message. Use this when you need to read, edit, or manage an existing message.
- Content: The text message you want to send or update. You can include plain text or formatted content up to 2000 characters.
- Attachments: Files or links associated with the message. You can provide a File ID, a URL, or the file content directly.
- Filter: Choose how you want to retrieve messages. You can select to get a specific message by ID or retrieve all messages from the channel.
- Top: The maximum number of messages to retrieve when fetching a list of messages.
- After ID: A message ID used as a reference point to retrieve messages that come after it.
Outputs
This component provides the result of your Discord action, allowing you to pass data to other parts of your workflow.
Output Data Example (JSON)
The component returns a structured data object containing details about the message. You can map these values to other nodes to analyze or store the information. json { “id”: “123456789012345678”, “content”: “Hello from Nappai!”, “channel_id”: “987654321098765432”, “author”: { “id”: “111222333444555666”, “username”: “NappaiBot” }, “timestamp”: “2023-10-25T14:30:00.000000+00:00”, “embeds”: [], “attachments”: [], “status”: “success” }
Connectivity
This component typically connects to other workflow nodes to automate message handling. For example:
- Connect to a Trigger component to act on new messages received in a channel.
- Link its output to a Data Processing node to analyze message content or extract information.
- Use the output in a Notification node to send alerts based on Discord interactions.
It serves as the interface between your Discord account and the rest of your automation logic, ensuring smooth data flow.
Usage Example
Sending a Welcome Message: When a new member joins a server, you can use this component to automate a welcome. Connect the Discord channel ID where the member should be welcomed. Enter a greeting in the Content field. Nappai will automatically send this message to the specified channel using your configured credentials. If you have multiple channels, you can use Mapping Mode to send the welcome message to each channel in a batch.
Tips and Best Practices
- Ensure you have the necessary permissions to send or edit messages in the target channel.
- Use the Message ID when you need to read, edit, or react to an existing message instead of creating a new one.
- Enable Mapping Mode if you need to process multiple messages or send bulk notifications efficiently.
- Keep your Channel ID and Message ID as strings to ensure compatibility with Discord’s system.
- Use Attachments to share files, images, or links along with your messages for richer interactions.
Security Considerations
- Always use a Bot Token with the minimum necessary permissions to enhance security.
- Store your credentials securely in the Nappai panel; never share tokens publicly or hardcode them in workflows.
- Review the permissions granted to your Bot to prevent unauthorized access to sensitive channels.
- Regularly audit your Discord application’s settings to ensure they align with your automation requirements.