Message
Message connects your flow to Discord through your bot to work with the messages of a channel: post a message, with file attachments if you want, read the channel’s messages or a specific one, and delete a message.
It is useful to keep a community or a team that organizes itself on Discord informed, or to let an agent read what is written in a channel and act on it.
When to use it
- Announce every new article or video you publish in your community’s news channel.
- Alert the technical team’s channel when a process fails.
- Read the new messages of a support channel so an agent can prepare answers.
- Delete messages the bot posted by mistake.
Configuration
You need a Discord API credential with the Public Key, Application ID and Bot Token of your application, which you find in the Discord Developer Portal. The bot must be added to your server and be allowed to see and write in the channel. See Credentials.
| Field | What it does |
|---|---|
| Credential (required) | Your bot’s Discord API credential. |
| Operation (required) | What the component does. See Operations. |
| Channel ID (required) | The ID of the Discord channel. You copy it in Discord by right-clicking the channel, with developer mode turned on. |
| Content | Only in Send Message. The message text. |
| Attachments | Only in Send Message. Files attached to the message. Connect them from a component that delivers files or pass their link. |
| Filter | Only in Get Messages. All Messages returns the channel’s messages; By ID returns one message. Default: All Messages. |
| Message ID | The message’s ID. Required in Delete Message and in Get Messages with By ID. |
| After ID | Only in Get Messages with All Messages. If you give a message ID, it returns only the messages posted after it, from oldest to newest. If you leave it empty, it returns the channel’s whole history. |
Operations
| Operation | What it does |
|---|---|
Send Message | Posts a message in the channel on behalf of your bot. |
Get Messages | Returns the channel’s messages or one message. |
Delete Message | Deletes a message from the channel. |
Output
The Data output returns the messages you worked with: their ID (id), the channel, the author (author_username), whether a bot wrote it (is_bot), the text (content) and the date. Send Message also returns the attachments. Delete Message returns a confirmation.
If Discord rejects the operation, for example because the bot has no permissions in the channel, the result has status set to error and the reason, instead of stopping the flow.
You can connect the result to an agent to read and reply, or keep the ID of the last message to use in After ID next time. The component can also be connected to an Agent as a tool. See Tool Mode.
Example
A gaming community wants to announce every new tournament.
- The new tournament reaches the flow with its name, date and sign-up link.
- Add Message with the
Send Messageoperation. - In Channel ID, paste the ID of the announcements channel.
- In Content, write
New tournament:followed by the name, the date and the sign-up link.
Good practices
- To read only what is new, keep the ID of the last message read and use it in After ID on the next run. Reading the whole history of a very active channel takes longer.
- Check in your Discord server that the bot’s role can see the channel, read its history and send messages.