Skip to content

How to create Discord bot with Power Automate

Discord is a popular chat app, especially among gamers. Over the past six months I have grown very fond of it and wanted to see if I could do something fun with the Discord API. And you know what? It’s really easy to make your own Discord bots using Power Automate. Absolutely no coding skills required!

In this blog post I’ll show you how to quickly set up a Discord bot and use Power Automate to post content to your Discord Server.

To get started, there are some prerequisites:

  • You should know how to build very simple flows in Power Automate (basically you should know how to add triggers and actions, how to use dynamic content and how to test flows)
  • Using HTTP actions in Power Automate requires either a trial license or, for example, Power Automate per User plan
  • Discord account (you can create one for free)
  • Discord Server in which you have administrator rights (you can create one for free)

How to set up Discord bot

First part of the magic happens on Discord Developer Portal. That is where you set up our Discord bot.

Log in to the Developer Portal and create a new application:

You can ignore all the general settings, though I uploaded a profile picture to make it more pretty ?

You can add a new bot after you have created the application:

The username and the profile picture you set here will be visible on the Discord server when the bot posts content.

When we are happy with everything, we can hit “Reset Token” button to get the token for the bot. Make sure to save it!

Now go to OAuth2 settings and choose OAuth2 URL Generator:

First select “bot” from the scopes. The bot permissions become visible after this. To post content to the server the bot only needs “Send Messages” permission:

When you have selected the scope and the bot permissions, copy the generated URL to your browser and open it. Now you should be able to authorize your bot to enter your Discord server:

Once you have completed the authorization process, you can go to your Discord Server to check that you can see the bot among the server members.

How to use Power Automate to post as the Discord bot

The second part of the magic happens in Power Automate. But first we need to figure out how to use Discord API. If you want to learn some API basics before proceeding, take a look of my previous blog post How to use API with Power Automate. It’s okay to not understand any of this though, as long as you are good at following instructions ?

According to Discord API documentation the base URL for HTTP requests is https://discordapp.com/api/. And to send messages to channels, the end point is /channels/{channel.id}/messages.

So to post to the channel we need to find the channel ID. The easiest way to grab it is by enabling Developer Mode on Discord. You can enable it from your User settings, under the Advanced tab:

When you have enabled the Developer Mode, you can right-click your server name to copy its ID:

Now we can build something simple to try it out. To post content as the bot, we need to add an HTTP action to the flow:

Fill in the request details:

Method:
Post

URI:
https://discordapp.com/api/channels/{channel.id}/messages
(instructions above how to get channel ID)

Headers:
Authorization | Bot {token}
(The bot token we saved earlier)

Body:

{
  "content": "Hello world!"
}

Run the flow. If everything works, you should see a message on your Discord server sent by the bot.

Now we can start doing fun things with the bot! And by we, I mean you… My example here is rather unsexy; I am using the RSS trigger “When a feed item is published” to automatically post new Forward Forever blog posts to the Discord Server ?

Body:

} 
 "content": "<<Primary feed link as a dynamic content>>"
}

Now when a new blog post is published, the bot automatically posts it on the server for everyone to enjoy:

Here are some other ideas what to do with your bot:

  • Any kind of news, obviously
  • Stock market stuff
  • Weather updates
  • Birthday wishes
  • Daily comics
  • Sport results
  • Jokes

And don’t forget that you can mix and match APIs to build cool stuff. There is no reason to stick with out of the box actions ?

And remember, if you need help, we’re here too.

citizen developerlow-codePower Automate

3 responses to "How to create Discord bot with Power Automate"

    1. I have not experimented with that myself, but I am fairly sure it’s possible. I have done a Telegram bot this way, making it react to messages… But I didn’t like the fact that the flow was basically listening and recording ALL the conversation so I turned the flow off.

Leave a Reply

Your email address will not be published. Required fields are marked *