What is a Discord Chatbot and how to create it?

By Joren Wouters Updated on

What is a Discord Chatbot and how to create it?

Discord has become one of the main channels for content creators to create their private communities.

And with 963 million messages being sent on Discord every day, a chatbot can become interesting to automatically reply to messages in your Discord server.

In this tutorial, I will cover:

  • What a Discord chatbot is and why you need one
  • How to create your own Discord Chatbot, without using any code
  • And how to add your chatbot to your own Discord server

Let’s dive in!

 

What is a Discord chatbot?

chatbot is an automated conversation partner. It facilitates a conversation between a human and a computer.

So a Discord chatbot is an automated conversation partner on Discord.

Usually, when you have a conversation, you are talking to another human. But with chatbots, you are not talking to a human, but to a computer that can automatically talk back based on your questions and answers.

 

Why should you create a chatbot on Discord?

Discord has 140 million users that are using Discord each month.

discord-monthly-users

And together, they are accountable for sending 963 million messages each day.

discord-messages-stats

That’s a lot of messages sent every day!

So the reason why you should use a chatbot on Discord is that it can take a lot of time to reply to each and every message. And by using a chatbot, you can:

  • Automatically reply to standard questions in your Discord server, such as “When are you going live” and “Can I have your gaming cheatsheet”
  • Reply to questions when you are not actually online

 

How to Create a Discord Chatbot

Now it’s time to create your own Discord chatbot.

And to do this, we are going to use Xenioo as our chatbot builder. So if you don’t have a Xenioo account yet, just click the button below and create a free Xenioo account:

Create Xenioo Account

The best part about Xenioo is that it is an omnichannel chatbot builder. That means that you can create one chatbot and just with the push of a button you can publish it on more than 10 channels (Discord, Facebook, Instagram, WhatsApp, etc.)

Once you have created your Xenioo account, you can just log in and click on Create New Bot:

xenioo-create-new-bot

Xenioo already creates a pre-built flow for you that gives you a kind of example of how you can start your bot.

Let’s say, we are a content creator about games and we have shared a gaming cheatsheet and we are going live every Tuesday.

Then, if someone is asking in our Discord channel “Can I have the cheatsheet” and “When are you going live”, we want to automatically respond to that.

So, let’s start with the cheatsheet!

In Xenioo, you can click on the + button in the left-hand corner to add a new flow to your chatbot:

xenioo-add-new-behavior

By the waya chatbot flow in Xenioo is called a “behavior”. Just so you know 😉 

On the right-hand side, you can click on the Settings button:

xenioo-behavior-settings

And then we can give a good name to this behavior so we can easily find it. Let’s call it “Gaming cheatsheet” and click on Save:

xenioo-add-behavior-gaming

Then inside the Start interaction, there is already a text message. So we can just click on this text message, edit the text and click on Save:

xenioo-edit-start-interaction-gaming

By the way, you must click on Save, otherwise, Xenioo will not save any of your changes!

Because we are giving away a free cheatsheet, we want users to automatically download it inside Discord. To do that, we can click on the Tool icon and click on Add new action:

add-new-action-xenioo

Under Content, you can select the File download element:

xenioo-file-download

Here, you need to set it to Upload to Storage, give a friendly name to your file and Upload a file:

xenioo-upload-file

But we only created the chatbot flow just yet. We haven’t set this up so that it responds to specific words. To do that, just click on the Art icon (View global bot operations):

xenioo-view-global-bot-operations

Then, we can set up a global bot operation. What this does, is that it automatically responds with a flow when a user says a specific keyword. So, just click on Add bot operation:

xenioo-add-bot-operation

And select Text parse:

xenioo-text-parse

Then, you need to set the Control expression to “gaming cheatsheet”, the target variable to “last_user_message” and the Go To to the Start Interaction of Gaming cheatsheet (the flow we just created):

xenioo-bot-operation-text

What this does, is that every time a user says “gaming cheatsheet”, the chatbot will automatically respond with “Here is your gaming cheatsheet:” and gives the gaming cheatsheet file.

By the way, if you want that the chatbot replies to multiple keywords, you can just type in the keywords and separate them with the  “|” character.

That’s set up! Now we can create an automatic reply when someone asks when we are going live. So again, just create a new flow by clicking on the + icon and giving it the name “Live”.

Then, we will first duplicate the Start Interaction by clicking on Clone:

xenioo-clone-interaction

Now, we will remove the text message from the Start Interaction and add a new action to the chatbot called a Variable Conditional Switch (you can find this under “Flow”):

xenioo-variable-conditional-switch

And then we will check if the variable “last_user” is equal to “general”:

xenioo-condition-last-user-general

What this will do, is that it checks if the Discord bot has given a reply inside the #general channel or privately to a user. Because if they are in a private chat, we can ask for more private information, such as their email. And if we get their email address, we can also send them an email once we go live 🙂

NOTE: If you have more channels than just #general, I would recommend cloning this condition for every channel so that your chatbot is not going to give private replies in a group chat.

So the next thing we need to do is click on Add operation and select the Go to Bot Interaction (under “Flow”):

xenioo-go-to-bot-interaction

And then we can select the message we copied before:

xenioo-go-to-live-flow

In that message, we can set a general public response by editing the text message:

xenioo-public-reply-discord-server

What this will do, is that if the chatbot is triggered inside the #general channel, it will automatically reply with “We are going live every Tuesday at 5PM. If you want to get a reminder in your email inbox, please send me a message in a private chat 😉”

But, what will the chatbot do when they ask this question in a private conversation? Then, we can also ask for the email of the user!

So in the start interaction, we will add a text message saying” We are going live every Tuesday at 5 PM. Would you like to get a reminder in your email inbox? Just simply reply with ‘Yes’ or ‘No'”:

xenioo-start-interaction-condition-text

Then, we will add two options, by adding two Quick Reply buttons (You can this under “Content”):

xenioo-quick-reply-button

But before we go further, we will add three new blocks (called Interactions in Xenioo) by clicking the Puzzle icon at the top 3 times:

xenioo-add-new-interaction

Then, you can just click on the Button Text, set it to “Yes”, set the Trigger Text Expression to “yes” and select one of the interactions we just added under “Go To”:

xenioo-quick-reply-button-yes-live

Now, if someone replies to your question with “Yes”, they are getting Bot Interaction #2. Now, we can do the same by adding a “No” option, so that the flow looks like this:

xenioo-start-interaction-live

NOTE: Although we added two Quick Reply Buttons, these buttons are actually shown as text in Discord. This is because Discord doesn’t have buttons on its platform.

As you can see above, for the “No” option I edited the text to “No worries, it’s not for everyone.”

But for the “Yes” option, we want to ask for their email address.

So, we will ask for the email address with a simple text bubble and add a new action called Email address input (which you can find under “Input”):

xenioo-email-address-input

The Email address input element waits for input by the user and checks if that input is actually a real email address. If that’s not the case, it will automatically ask to fill in a correct email.

Then, just set the Go To element to “Bot Interaction #4” (which is the last interaction we added to this flow):

xenioo-connect-email-input

And add some text to that block, so the final flow looks like this:

xenioo-final-flow-live

So that flow works. And to let it automatically reply when someone asks when you are going live, we set up another Global Bot Expression that looks like this:

xenioo-global-bot-operation-live

Lastly, we need to remove the content of the fallback interaction for every flow in your chatbot.

So just go to the fallback interaction in each flow, click on the Text message and then click Delete in the top-right corner:

xenioo-delete-fallback-interaction

The reason why we do this is that the fallback interaction would normally trigger when the chatbot does not understand a question.

And because we are going to add this chatbot to our own Discord server, this would lead to very annoying messages every time a user says something the chatbot doesn’t understand.

To avoid these annoying messages, we simply remove the fallback interaction from every flow 🙂

Connect your chatbot to Discord

Now that our chatbot is set up and ready, it’s time to connect it to Discord.

In Xenioo, you can just click on the Publish button:

xenioo-publish-chatbot

And click on Discord:

xenioo-publish-discord

And here we need to fill in our authorization token. To get this token, we first need to go to the Developer Portal of Discord. So you can just click the button below and log in with your Discord account:

Discord Developer Portal

In the Developer Portal, you can click on New application in the top-right corner:

discord-new-application

And fill in the name of your chatbot and click on Create:

discord-create-application

Now, your application in Discord is ready. But, it is not a bot yet.

So to create a bot out of your application, simply click on Bot in the menu and click on Add Bot:

discord-add-bot

In the pop-up, just click on Yes, do it!:

discord-add-bot-to-app

And then you can click on Copy to copy the authorization token:

discord-copy-bot-token

This is the token you need to paste into Xenioo. After you’ve pasted it, just click on Save and Publish and this will connect your chatbot to Discord.

And that’s it! Now your chatbot is connected to Discord!

How to add your chatbot to a Discord server

But before you can talk to your chatbot, you first need to add it to your Discord server.

To do this, we need to go to OAuth2, click on URL Generator and set Bot as the scope:

discord-oauth-url-generator

And give some permissions to the bot and copy the Invite URL:

discord-generate-invite-link

When you go to this URL, you can select the Discord server you want to add your bot to and click on Continue:

add-chatbot-to-discord-server

Once you’ve done this, your Discord chatbot is automatically added to every channel inside your Discord server. Also, it will automatically say the Start Interaction inside your #general channel. If you want to avoid this, you can just simply remove the Start Interaction in Xenioo:

xenioo-remove-start-interaction

Now It’s Your Turn

And that’s how you can create your own Discord chatbot and add it to your Discord server.

Now I have a question for you:

Have you ever used a chatbot on your Discord server before? Why (not)?

Please let me know by leaving a comment below!

Leave a Reply