Create Custom Company Chat bots on Discord
Tags: tutorial, wayscript, bots, automation
Published: 2020-08-14 11:44:29

Introduction
------------

Bots today are an important part of Customer help services. With services used by millions of people, it’s difficult for Customer service people to handle all the problems addressed to them. Bots can be easily built and integrated into any services if you are using the Wayscript platform.  
So today, we are going to build a Customer help Bot for Discord.

Prerequisites
-------------

No prerequisites for this tutorial. However, you can read about the module we are going to use in this post.

*   Working with Discord Trigger
*   Working with conditionals
*   Working with Discord module

Trigger
-------

When someone will write a message in the help channel, we’ll capture the message and perform actions on it, and later send a response. For this purpose, we’ll use the Discord Trigger.

![Adding the Trigger](https://wayscript.com/blog_img/128/1.png)

Well, The trigger will depend on the action I add on the discord channel. It’s a pinned message.

![Pinned messages](https://wayscript.com/blog_img/128/2.png)

So basically we have three actions. But first, we have to configure the Trigger.

![Configuration of the trigger](https://wayscript.com/blog_img/128/3.png)

For the output, be sure to have Discord Message selected. This list contains information we’ll use to perform actions.

The conditions
--------------

Here we have three conditions, but exactly four. A message will be displayed if the user hasn’t entered a valid action, I mean a valid action is A, B or C. Nothing else. First, add the If/Else module.

![Adding If/Else module](https://wayscript.com/blog_img/128/4.png)

Once it’s done, we can add the conditions.

![Adding a condition](https://wayscript.com/blog_img/128/5.png)

If you want to add another condition, just click on Add Else if.

![Adding all the conditions](https://wayscript.com/blog_img/128/6.png)

Now we have different branches for our scenario. We are going to create a string variable where we’ll store the message we want to send.  
Then in the first branch concerning action A, add Create Variable module.

![Adding Variable module](https://wayscript.com/blog_img/128/7.png)

And then add this variable and text message.

![Text message A](https://wayscript.com/blog_img/128/8.png)

We are going to do the same for the second branch and the third branch.

![Text message B](https://wayscript.com/blog_img/128/9.png)

![Text message C](https://wayscript.com/blog_img/128/10.png)

Great. But it’s not finished yet. As I said earlier, we have four conditions. The Else will be executed if the message typed by the user is not equal to A, B, or C. Then we can add a custom message for this branch too.

![Text message Else](https://wayscript.com/blog_img/128/11.png)

Now that we have the text message, we can easily respond now via our Discord bot.

Discord Bot
-----------

Wayscript provides a Discord module you can use to read or write messages. Then, we can use this module to create the Help Bot.

![Adding Discord Module](https://wayscript.com/blog_img/128/12.png)

Once it’s added and you have configured the server, be sure to have a separate channel for this bot. In my case, I called it help.

![Configuring Discord Module](https://wayscript.com/blog_img/128/13.png)

Now, we can add inputs. Most importantly, we need the name of the Bot and the message. You can add an image to if you want to give a face to your Bot. ;)

![Discord Inputs](https://wayscript.com/blog_img/128/14.png)

Great! The Bot is ready and if you’ve followed exactly this tutorial your result will look like this.

![Wrong Message](https://wayscript.com/blog_img/128/15.png)

Feel free to clone this script and modify it as you want. You can create many actions as you can. The sky is the limit.

Conclusion
----------

Questions about this script or anything else? Join our [discord](https://discord.gg/VWbXSbj). We're always around to help. If you want to work the full script template, just find it [here](https://wayscript.com/user/mangabo_kolawole/BAUErWEE
        ).