?

Working on projects is the most crucial stage in the learning path. In this step, you must be able to put all the skills and knowledge you learned theoretically into reality. And this becomes even more important when it comes to Artificial Intelligence or data science.
As I began to study this field more deeply, I realized that finding application projects is not a hard task. We barely use Artificial Intelligence in many areas. Thus, we can find many new and different applications related to other fields such as medicine, engineering, accounting, etc. Although the most difficult thing is knowing what are the exact steps to follow in order to accomplish this specific project.
In this article, I am going to share with you my personal experience in creating and building my own AI Chatbot on Discord.

For those who have never heard about Discord, it is a popular group-chatting app that was originally made to give gamers or geeks a place to build communities and talk [1]. What is interesting about Discord is the fact that it has a developer portal where you can do many fascinating things like deploying your own AI chatbot. Therefore, you need to sign up and join Discord Developer Portal from here.
Before we start the real work, let’s talk, first of all, about the steps I followed to build my AI Chatbot. In fact, this project is part of Natural Language Processing Applications. NLP or Natural Language Processing is a technology that allows machines to understand human language through artificial intelligence. Find out everything you need to know about it [2].
Now, we are ready. Let’s get started!
1. Choosing what your Chatbot will do
Your first task will be to choose what service you want your Chatbot to provide. Will it be just a simple Chatbot? Able to answer normal questions and talk on its own? Or you want it to help you in your daily work? Or maybe suggest some healthy meals each day. It seems great! Doesn’t it? This first step lends a helping hand to know what specific data you must collect. If your Chatbot will answer general questions and be a normal talker, then you don’t need to feed it with specialized text data for example.

I mention here two ideas for inspiration:
- Healthy meals Chatbot: the chatbot suggests a meal based on your nutrition needs (proteins, fats, and carbohydrates). It must be linked with any food database so it can search for the best meal that fits perfectly your needs.
- Reminder Chatbot: It gives you an overview of your meetings and all the things that you have added to your agenda.
2. Collecting or creating text data
In this step, you can either collect text data that are available on data platforms or create your own data depending on what you want to make. There are many open datasets you can download and adapt to your project. You can check them from here.
If you want to create your own data, you better respect the following format so you can train your model using my main code without problems:
You can add as much as you want of tags as long as you respect the format. The AI Chatbot will commonly learn the patterns of all new sentences and associate them with the tags to get responses. We will explain how it does that in more detail in the next part.
3. Building and training the model
The NLP pipeline we are following in this project is shown below:

When the user writes a sentence and sends it to the chatbot. The model follows 3 basic steps. The first step (sentence segmentation) consists of dividing the written text into meaningful units. These units are the input of the second step (word tokenization) where they are divided into smaller parts called "tokens". These tokens are very useful for finding such patterns as well as is considered as a base step for stemming and lemmatization [3]. In the third step, lemmatization refers to a lexical treatment applied to a text in order to analyze it. After that, the model will predict the tag of the sentence so it can choose the adequate response.
You can check the main python code related to this whole part from here. This code is important to build and train the model. You can modify it to fit your project needs.
4. Deploying your model on Discord
In the beginning, you must sign up on Discord Developer Portal. Once you are done, Visit the Discord applications page and click on Create an Application. then write your application’s name.
When you click Save Changes, you can now create your own bot by clicking on Add Bot button. After that, you need to get and copy your token by hitting Click to Reveal Token.

This token is used in your bot main file in order to call it. You need to use client:run('TOKEN')
, replacing TOKEN
with the token copied above.
In order to deploy your model, you have to add the code below at the end of your main python file:
Do not forget to change ‘TOKEN’ by your own code.
Once you run the whole python code, you can open your Discord and start talking with you AI Chatbot. It will stay Online as long as you don’t interrupt the running of the python file.
I’m glad to have the opportunity to share my experience in building a simple and effective AI Chatbot. Best of luck with yours!
References
[1] Devon Delfino, ‘What is Discord?’: Everything you need to know about the popular group-chatting platform (2020), Business Insider, Tech Reference.
[2] Bastien L, Traitement naturel du langage : tout savoir sur le Natural Language Processing (2019), Le Big Data, Magazine de l’IA.
[3] Krishna, Tokenize Words and Sentences with NLTK (2019), Guru99, Education for ALL.