How To Code Your Own ‘Watson’ AI Bot In 50 Lines Of Code?


how to code ai bot 50 linesShort Bytes: Bots are the new apps and the bot store is the new app store. Combined with AI, bots are becoming more powerful each day and learning to do new things. In this article, I’ll tell you how to use IBM Watson API to create a Telegram speech-to-text bot in 50 lines of code.

Bots are the new apps these days and everyone is talking about them. Microsoft announced them as a part of their strategy to make Skype better and Facebook got them for Messenger. Talking about others, Telegram and Slack were already having them.

With time, more and more companies are realizing the potential of bots. With the evolution of artificial intelligence, it has become easy to make AI-driven bots that integrate easily with existing apps.

In this article, I’ll be telling you about an IBM Watson-powered AI Bot that could be a nice starting point for a lot of projects. Watson API is a great service to integrate with and it comes with good documentation and examples.

Recently, I came across a post on Hacker News in which Philipp Langhans, a software engineer, shared an article and described how to code a basic bot.

This AI bot solves the problem of voice messages that are not convenient all the time and you might not want to listen to them while chatting. The reason could be some public place or your friends.

Philipp tells how to create a speech-2-text bot that converts voice messages into text. To do this, as mentioned earlier, he takes help from IBM Watson — the smartest bot on the planet.

How To Code An IBM Watson AI Bot?

Setting up Watson for your AI Bot:

To get started, you need to sign up for 30 days Watson trial that will give you access to 2GB of runtime and container memory to run apps and unlimited IBM services and APIs.

After you are done with the sign-up and setting up your region and company, go ahead and explore the web UI as you’ll be needing it.

After this step, follow this easy to grasp documentation and create your speech-to-text service using the command line.

Now come back to the web interface, find the newly created service and obtain the credentials.

Setting up a Telegram bot in 50 lines of code:

This step is very simple and you need to start by adding the BotFather to you contacts. Now use /newbot command and follow the instructions like adding your name and username.

Make sure that you write down your API token. For more help, you can visit Telegram’s Bot guide.

After all is done, here is the open source code that you can use to create your own bot. Take a look:

You can also try out this bot on Telegram by adding @speech2textbot ( to you contacts or any chat.

Here’s what it should look like with a transcript of all the voice messages:

telegram ai bot

Go ahead and make on for yourself. Good luck!

Want to learn to code? Visit our store and get amazing deals on eLearning courses.

Adarsh Verma

Adarsh Verma

Fossbytes co-founder and an aspiring entrepreneur who keeps a close eye on open source, tech giants, and security. Get in touch with him by sending an email — [email protected]
More From Fossbytes

Latest On Fossbytes

Find your dream job