# Discord

Discord

Pipedream supports two Discord integrations:

If you just need to send messages to a channel, use the Webhook integration.

The Bot integration lets you interact with the Discord API to programmatically create channel invites, kick users from a guild, and more. You'll need to create your own bot and add it to your guild before using this integration. We describe that process below.

You can also use both types of integrations in the same workflow. Read on to learn more.

# Discord Webhook

The Discord Webhook integration is the easiest way to send messages to a channel.

You can use Pipedream to automate any workflow where you need to receive a message in Discord. For example, you can:

Watch this video to see how to create a new Discord webhook using Pipedream, and how to send the name of a random Star Wars character to a Discord channel once an hour:

See the finished workflow here. We'll walk through the setup described in the video below.

# Using the Discord Webhook integration

To use this integration, add a new step to your workflow and choose the Discord Webhook app:

Discord Webhook integration

select the Send Message to Channel action:

Discord send a message to channel action

then connect your Discord account. When authorizing Pipedream access to your Discord account, you'll be asked to create a webhook for your target Discord server and channel.

If you'd like to create another webhooks in another channel, you can create another Discord Webhook connection. You can send a message to any number of Discord webhooks within a single workflow.

# Example: Send an embed

Discord embeds are richly-formatted messages that include images, fields, and text, arranged in a custom way. You can send embeds using the Discord Webhook Send Message to Channel action in Pipedream.

Copy this example workflow to get started. This workflow formats an example embed in the format_embed_message step, exporting it for use in future steps.

this.msg = [
  {
    title: "Hello!",
    description: "Hi! :grinning:",
  },
];

In the next step, we use the Discord Webhook Send Message to Channel action. This action expects either a Message or an Embeds parameter, which is delivered to your target channel. In this example workflow, we've selected the Embeds param, turned structured mode off (this allows us to enter an expression for the Embeds array), and entered the value {{steps.format_embed_message.msg}}, which evaluates to the array of objects we formatted in the step above:

Discord embed parameter

This should send a message to Discord that looks something like:

Discord embed message in channel

# Discord Bot

The Discord Bot integration should be used when you have a Discord bot that you've added to a server, and you want to automate interaction with the Discord API using Pipedream. You can use this integration to:

  • Accept HTTP requests from a webhook and automate common server actions, like automatically sending any new user who signs up for your app a channel invite.
  • Run code on a schedule to regularly check your Discord audit log and send you an email of any events you want to monitor.
  • Any other administrative action you want to drive programmatically, triggered from any event.

If you just want to send messages to a channel, check out the Discord Webhook integration, instead.

Watch this video to see how to create your own Discord bot, add it to a server, and make some requests to the Discord API from Pipedream:

See the finished workflow here. We'll walk through the setup described in the video below.

# Using the Discord Bot integration

You'll need to create a Discord bot and add it to your server before you begin. Watch the first couple minutes of the video above, or follow the instructions in this guide to create that bot and add it to your server.

Once that's done, add a new step to your workflow and choose the Discord Bot app:

Discord Bot integration

select any of the actions that appear:

Discord bot actions

and connect your account. You'll be asked to add your Discord bot token, which you can find under the Bot section of your app. Then deploy your workflow and start making API requests.

# Requesting more Discord Bot Actions

To request a new Discord Bot action, please file an issue on our Github repo.

# Limitations of the Bot integration on Pipedream

Right now, the Discord Bot integration cannot utilize the Discord Gateway to receive events via websockets or make API requests that require an initial connection to the gateway.

Please reach out if prevents you from building a workflow. We're happy to prioritize support for this in the future.

# Discord Event Sources

Event sources let you trigger workflows on new events from Discord. For example, you can create a source that listens for new messages in a Discord channel, triggering a workflow on each new message.

# New Messages in Channel

Read the Github docs to create an event source that emits a new event each time a new message arrives in a Discord channel. This lets you trigger a Pipedream workflow on each new message, or listen for new messages via Pipedream's SSE interface or REST API.