Always On Discord Bot 🤖 in The Cloud ⛅️ with the AI Powered Chatbot
The intent of this blog post is to help you deploy your bot in the Cloud, and power it with AI based Chatbot. This entire process will be free of charge using free tiers for the Cloud Containers hosting (Kubernetes), or free accounts. And yes, this is super simple process — with little or no installation of unknown software (thanks to Docker!).
Apex Legends and Fortnite start new seasons in November. And you want to keep your tricks provided to your Discord community via text channels? Read on to learn on how to do it quickly. How to create a simple FREE of CHARGE process to deploy your Always On Discord Bot. With the power of the free tier of the Cloud, Docker, and open source Kubernetes.
The Plan
- (optional) the basics getting your Docker Chatbot running
- (optional) connecting your AI based Chatbot
- claiming your free Kubernetes one node “cluster”
- deploying “Always On” chatbot in the Cloud in the Kubernetes cluster
- cleaning after the work
- next steps.
Sounds interesting? So just follow the below steps, and join me for the webinar/watch the recording here: https://www.crowdcast.io/e/discord-chatbot-with-ibm-2
(optional) The basics on getting your Docker Chatbot running
This step is optional — necessary only if you want to build your own container.
In order to get your container with a chatbot for Discord running you need to use Docker Desktop. The details are in the previous blog post on the same subject — follow the instructions here (a friendly link): https://medium.com/voice-tech-podcast/yeah-a-discord-ai-powered-bot-baby-d9cb73b4775d?source=friends_link&sk=5fd7e544211b3f64b8e5ca476dd547c9
Or simply get to my github repository and download the code (you can simply download a zip file), or if you use git you can use the following instructions:
git clone https://github.com/blumareks/discord-bot.git
cd discord-bot
When you have the code downloaded / cloned now it is the time to build your container with a bot, and run it.
docker build -t <YOUR_DOCKER_ID>/node-container .docker run -e token="<YOUR_TOKEN>" -d <YOUR_DOCKER_ID>/node-container
Alternatively you can use my published container without building it for ping pong exercise:
docker run -e token="<YOUR_TOKEN>" -d blumareks/node-container:1.0
(optional) connecting your AI based Chatbot
Optional step here — you can stop the container with just ping pong functionality, and run the AI Based chatbot. That requires some setup of the Watson Assistant — the AI based chatbot backend. But when it is done, you can easily power your bot with great cues, jokes, etc.
The details on how to connect the Docker based chatbot to AI based chatbot can be found here (a friendly link): https://medium.com/zero-equals-false/add-ai-to-discord-bot-with-watson-fdcca207869d?source=friends_link&sk=6e0c5f7e711b8f6fb9c3959c4cddaa24
Alternatively after setting up your Watson Assistant you can run this command (so you would use my blu-bot):
docker run -e token=”<Discord-bot-token-here>” -e assistantId=”<AssistantId-here>” -e assistantUrl=”<Cloud ⛅️ Service-Assistant-URL-Here>” -e apiKey=”<Cloud ⛅️ Service-Assistant-apiKey-Here>” -d blumareks/node-discordbot:2.0
Now your bot works with Watson Assistant.
claiming your free Kubernetes one node “cluster”
Previous two optional steps are required if you want to change the functionality of the bot. Now we are going to deploy the chatbot container in the cloud. How to do it you could discover by watching a recording of the webinar here: https://www.crowdcast.io/e/discord-chatbot-with-ibm-2
Now you can create your own Cloud based cluster (1 node free cluster) just use this link to invoke IBM Cloud registration/signup/login page (this URL gives an author = me some brownie points): https://ibm.biz/Bd2CUa
As soon as you log in to IBM Cloud — you would want to navigate to the Kubernetes page: https://cloud.ibm.com/kubernetes/ You can also use the hamburger 🍔 menu to open the Kubernetes.
Pick the Kubernetes tab from the menu.
When you are there, now you can create the FREE cluster (only one per account):
Then upgrade your account to Pay-Go account. You need to use caution, since as soon as you spin paid services or exceed free tier you are going to pay for them as much as you use them. The information you are going to put in:
Now you can spin your free cluster — note it is only for 30 days. After that time you need to restart it.
Now the cluster is being provisioned:
When your cluster is ready — you can go to the next step.
Congratulations! Your free cluster is ready to receive the containers and serve them free of charge!
deploying your Always On chatbot in the Cloud in the Kubernetes cluster
When you are ready with the Pay-Go account, and you started your cluster your are ready for the next step — deploying your container in the cloud.
First start a cloud shell terminal (yes, you do everything in the cloud).
When your browser based shell is ready, you can connect to it from CLI. Go to Actions button in the cluster view.
Now you can select the Connect via CLI action.
On the next screen select the ibmcloud command to connect to your cluster (step 2):
then you are able to connect to your cluster. Use the command from the dashboard (CLI)
Test connection by typing
kubectl get nodes
Now you can deploy your container as a pod in the Kubernetes cluster
kubectl run discord-bot-deployment --image=blumareks/node-discordbot:1.0 --env="token=YOUR-DISCORD-TOKEN"
If you want to use the Watson Assistant you would need to pass the other env variables:
kubectl run discord-bot-deployment --image=blumareks/node-discordbot:2.0 --env="token=YOUR-DISCORD-TOKEN" --env="assistantId=YOUR-assistantId" --env="assistantUrl=YOUR-assistantUrl" --env="apiKey=YOUR-apiKey"
You need to expose its service (outbound part) as the second step.
kubectl expose deployment.apps/discord-bot-deployment --type=NodePort --port=3000 --name=discord-bot-service --target-port=3000
Cleaning after work
So now it is easy to delete the bot deployment:
kubectl delete deployment discord-bot-deployment
And also delete the bot service:
kubectl delete service discord-bot-service
You might want to delete also the cluster.
next steps
I am planning on running the webinar on doing the Bot for the voice channels on Discord. That is going to be fun… I am not sure if I succeed…
If you like this blog post — clap 👏! You can also follow me on Twitter: https://twitter.com/blumareks
See you at the webinar here: https://www.crowdcast.io/e/discord-chatbot-with-ibm-3
Please read my book on Serverless Swift: https://www.apress.com/us/book/9781484258354
Thank you for reading this blog post/book! 📖