DEV Community

Cover image for Discord chatbot 🤖 with IBM Watson
Ivana
Ivana

Posted on • Updated on

Discord chatbot 🤖 with IBM Watson

Not really that I was going to create a custom chatbot for my son's Discord friends as they play a new season of Fortnite 😄, but more likely to enhance it with AI services based on IBM Watson and give a head start with Watson Assistant - a comprehensive chatbot framework with built-in machine learning capabilities.

And this is how it all started...

Alt Text

Let’s learn more about:

Discord

Discord is an American VoIP, instant messaging, and digital distribution platform designed for creating communities used by over a hundred million people to hang out and talk with their friends and communities.

Since its launch in 2015, Discord has been growing explosively – with over 14 million active daily users, which is more than Slack which has just 10 million daily active users. In May 2019, Discord reached over 250 million users.

Chatbot

A chatbot is a software application that simulates human conversation through voice commands or text chats or both. Chatbot, short for chatterbot, is an Artificial Intelligence (AI) feature that can be embedded and used through any major messaging applications.

IBM Watson

Use IBM Watson Assistant to build your own branded live chatbot into any device, application, or channel.

You will use free of charge AI-based chatbot engine with Watson Assistant from IBM Cloud.

Now, let’s get started with:

-How to add a chatbot to Discord using IBM Watson
-Intro to IBM Watson Assistant
-Deploying the chatbot in IBM Cloud

STEP 1. Connect to Discord service

Simply log in to your Discord account, or create a new one, and navigate to https://discordapp.com/developers/applications/

After making your new Discord server add the bot there:

Alt Text

Follow the next few steps to add the bot to your server, this is the URL to follow and add the bot:

https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot

You can find and copy CLIENT-ID in the General Information tab:

Alt Text

The following step is to click Authorize:
Alt Text

After you click Authorize the bot should be in the list of the users:
Alt Text

STEP 2. Getting the Ping-Pong BOT in Node.js, the Discord Node JavaScript library

About Node.js

Node.js allows you to run JavaScript on the server. It's an open-source server environment and one of the most popular technologies nowadays to build scalable and efficient REST API's. Essentially, Node.js is a server-side runtime environment that allows us to execute JS outside the browser's domain.
Node.js popularity around the world is constantly growing. It’s no wonder that over 177,393 websites (some of them being the BIGGEST players on the market) already put Node.js on their backend, such as:

  • Netflix, the world's leading Internet television network is one of those top companies that trusted its servers to Node.js

  • Uber has built its massive matching system on Node.js

  • PayPal, one of the largest fintech leaders, has also trusted their back-end development to Node.js

  • LinkedIn, the world’s biggest professional social network, too, shifted its server-side code entirely to Node.js

  • Ebay, a multinational e-commerce company

Let's start with:

Setting Up npm (Node Package Manager) and before we continue, let's make sure your environment is all set to work with npm that is automatically installed along with Node.js. To confirm you have node installed, enter the following into your command line:
node -v

If a version appears, you have Node.js. If, by chance, you do not have Node.js installed, you can use the Node Version Manager to install Node.js and keep it up to date.

The next step would be:

mkdir mybot
cd mybot
npm install discord.js

Create file index.js with the Example content (following the documentation here https://discord.js.org/#/

Alt Text

Now you can replace the token with the token of your bot (It's NOT recommended to share the token 😄 and then run it with:

node index.js

If everything is connected correctly you have the bot online (Logged in as ivana#7035!):

Alt Text

STEP 3. Chatbot AI features with IBM Watson Assistant

  1. Adding the AI-powered chatbot backend

In order to create an AI-based chatbot engine, you will need the FREE Lite Account in IBM Cloud. Try Watson Assistant, just use this link to invoke IBM Cloud registration/signup/login page.

I used this URL, it gives to Speaker of Discord chatbot with IBM Watson on IBM Cloud Webinar Marek Sadowski some brownie points 😄

You can simply go to Catalog and choose Watson Assistant:

Alt Text

After you choose and create Watson Assistant from IBM Cloud Catalog, the AI-powered engine from IBM is ready to be tested.

For more details you should follow the documentation how to Create your first Assistant-powered chatbot:

Alt Text

Next steps

To learn more check Discord chatbot with IBM Watson on IBM Cloud Webinar 3 part series register here .

To connect with me please check my Github, LinkedIn or Twitter.

Thank you for reading!

Top comments (3)

Collapse
 
shadowtime2000 profile image
shadowtime2000

Cool! Mainly people use Discord bots for integrations with games and fun commands. I have never seen a Discord bot that uses some sort of AI. But who knows, maybe it will become the new type of Discord bot.

Collapse
 
blumareks profile image
Marek Sadowski

Thank you @ivana and @shadowtime2000 for comment and kind words - I am trying now to add the voice capabilities to the Discord Bot.
I think my next startup solution will be based on Discord and the AI powered chatbots.

Collapse
 
ivanadokic profile image
Ivana

Yes, Discord has experienced rapid growth and is becoming increasingly popular even among those with little interest in video games. One of the most attractive features of Discord from a chatbot developer’s perspective is its support for programmable bots that help to integrate Discord with the outside world and provide users with a more engaging experience. Depends on what service you want your chatbot to provide but it's a wide range of services, including moderation assistance, games, music, internet searches, payment processing...