Terjmat is a multilanguage translation service integrated with the Telegram application that you can use to make chatbot translations easier. The IBM Language Translator service can connect to other IBM services, and these services can be linked to the Telegram application using a Node-RED app. When you link the services, users can easily use the translation app by sending text or voice to your bot. In this tutorial, I walk you through the steps to create a Node-RED boilerplate that’s available on IBM Cloud and link Terjmat to a Telegram app as the user interface using Node-RED flows – in under 20 minutes and using only IBM Cloud services.
After completing this project, you will understand how to:
- Create a Node-RED flow
- Create a Telegram bot
- Create a translator dialog using Language Translator, Speech to Text, Text to Speech IBM services
- Integrate Node-RED with Telegram as an interface for Terjmat
To complete the project, you need the following:
- An IBM Cloud account.
- The Language Translator service
- The Language Identification service
- The Speech to Text service
- The Text to Speech service
- A Node-RED starter app
- The Telegram app installed on your mobile device
For this project, the estimated times are:
- Creating a bot on Telegram should take less than 5 minutes.
- Developing the complete application on Node-RED should take less than 20 minutes.
- Completing the entire project should take approximately 25 minutes.
Creating a Telegram bot
After installing Telegram on a mobile device, search for “BotFather.”
After you find it, send a
/newbot command and follow these instructions:
- Set a name.
- Set a username.
- Save the access token for future use.
Note: Make sure to create instances of all of the required services for this project before moving to the next steps.
Create a Node-RED starter app
Follow the steps in this tutorial, “Create a Node-RED starter application.”
Configure the Telegram bot
This is a Node-RED editor and you need to add Telegram nodes. To do this:
Select Manage palette from the upper right menu.
From the Manage palette menu, click the Install tab then search for telegram.
Install node-red-contrib-telegrambot and close the palette menu.
Search for telegram nodes from the upper left filter section, then drag the Telegram receiver and Telegram sender nodes to the Flow.
Double-click the Telegram receiver node and click the pencil icon for configuring your bot credentials.
Complete the Bot-Name and Token fields according to the bot credentials that you created earlier.
Double-click the Telegram sender node, select the bot credentials that you created in the Telegram receiver node (example_bot in my case), and click Done.
Now you have configured the Telegram part on Node-RED. You can test it by connecting the Telegram receiver node to the Telegram sender node.
You can send a message to your bot on Telegram and it echoes the message you wrote. That’s because you forwarded the message payload directly to the Telegram sender.
Connecting IBM services
Now that the bot interface is connected to Node-RED and ready to use, let’s start integrating all of the services with the Node-RED application.
Go to the Node-RED application in IBM Cloud and click the Connections tab in the left menu. Click Create connection.
Connect all of the required services.
Restage the app to configure the new changes.
Create the flow
Copy the code from the Terjmat flow file and import it into the Node-RED clipboard.
Configure all of these nodes: Speech to Text, Text to Speech, Language Translator, and Telegram.
Your flow should look like the following figure. Click Deploy.
Testing your application on Telegram
Node-RED can make things much easier. This tutorial walked you through the steps to create a translator with a Telegram interface. This is a simple and basic example that you can modify and enhance for your own use.