step by step creating the bot and adding artificial intelligence to it

Let’s explain to you how to create your own AI bot on Telegramso you can interact with it at any time. In this way, the bot will be yours and you can put the model of artificial intelligence whatever you want, whether Gemini, ChatGPT, Claude or whatever.

To carry out this task we are going to use two services. First we will use BotFather of Telegram to create the bot, and then we will use the service Make to create a workflow or workflow that adds an AI, which in the case of our step by step will be Gemini, but you can use any other.

But before we start, I must remind you that even if the bot is yours, everything you write will be sent to the Make servers to process the workflow and the AI ​​you choose. Therefore, be careful with writing personal details that may violate your security or privacy, because you will be giving them to these two companies.

First you must create the bot

Creabot
Creabot

The first thing you have to do is create a bot on Telegram using BotFather. To do this, write a message to the bot @BotFather and write to you as if you were a new user. Type the command /newbot to create a new bot, to which you have to give a name to identify yourself and a unique username to access the bot whenever you want.

When you do it, it will give you two things, first the username and address of your bot to access it, and second an access token with various figures and letters. You have to save this token to use later.

In the message that Telegram will return to you, will also give you a link to the bot you createdwhich will basically be t.me/@botname. This will be important for later.

Also you can use BotFather options to customize your botputting a profile image, a description or whatever you want. We have explained all this to you in our post about BotFather.

Now get the API of an AI

Create API
Create API

Now we have to get an API from an AI. We will use the Free Gemini APIwhich although it has some limits in its use, will be useful for some tests without spending. To get it go to the website aistudio.google.com and sign in with your Google account. When you do, in the bar on the left at the bottom click on Get API Key.

Create the API
Create the API

Now you have to click on the option Create API key that appears at the top of the screen you have created. This will open a window where you have to create the project for which you are going to use it in order to identify it, for example “Bot Telegram IA”. When you create the project, you can now create the API.

When you have created the API, you will see that it appears in the list of API keys. You just have to click on the left, below where it says Clueand a window with the API will open, starting with “AIza–“.

Now create the workflow

Watch Updates
Watch Updates

Now let’s create the workflow or workflow using the service Make. Within this program we are going to create a new scenario. We start by clicking on the initial + for the first step, for which you have to write Telegram and choose the option Watch Updates within the options related to Telegram that will appear.

Connect bot
Connect bot

When you do this the first time you will have to create a webhook. Basically, it will be like creating a connection, and by doing so you will be able to give it a name and when establishing the connection, you will only have to type the Telegram bot token that BotFather gave us.

Run Once
Run Once

Once the connection is established, open the Telegram bot that you created in the app, and click on Start. When you do this, the message /start will be written. When you do this, go back to make.com and, at the bottom, press the button Run eleven. This will simply test the connection with the bot.

Generate response
Generate response

Now, click on the + button on the right of Telegram Bot to generate a new module, and you will have to choose the module to generate an AI response. Simply type the name of the AI ​​you have a token for, in our case Gemini, and choose the option that means generating a response.

Connect Gemini
Connect Gemini

A window will open to configure your AI. In it, you have to establish a connection using the APIwhich is what we have done above. You will also be able to choose the model you want to use. Keep in mind that the more advanced the model, the more credits the AI ​​will use, and your free API will have limited credits.

Rest configured
Rest configured

Now comes the most complex part of all. You have to go to the section messages of this window, and in Item 1, in the field Role you have to put User. Now, in Parts you have to fill out Item 1 by putting in Message Type the option textand in text just below choose option 1. Message: Text.

As before we have already executed our project with the Telegram bot, when you click on the value you will get suggestions based on the results of the bot. In these suggestions you will see the 1. Message: Text. You will recognize it in the next window because it is where it says /start, which is what we wrote to the bot. Down in System instructions go to Promptsand in the value of Prompt 1 you also have to put 1. Message: Text.

Below, in Response Modalities you have to **choose only the option textdeactivating Imagebecause with the API we will not be able to generate images in our country.

Reply
Reply

Now we are going to create the third step, that of sending the AI ​​response to the Telegram bot. To do this, create a new module, look for the Telegram options and choose the option Send a Text Message or a Reply.

Chatid
Chatid

When you do this, you will go to a window where the first thing you have to do is write the ChatID of the conversation. Here, when the content suggestions window opens you have to open the section Messageand inside open Chat and click on ID. This way it will remain as Message: Chat: IDwhich will appear in the window with a code.

Complete
Complete

Below, in the field text you have to choose the option 4.Result of AI options. Come on, when the side window opens, look at the recommendations related to the chosen AI, in our case Geminiand then choose the results option. Finally, in Parse Mode choose markdownso that the text returned to you does not have asterisks or strange things.

Run Once
Run Once

As a final touch, at the bottom click on Run Once. In the window that opens, choose Wait for new data to leave it executed waiting for new information. Then, you will go to a window where Run scenario you must choose Immediately so that when you write to the bot everything runs instantly, and below put the number of times you can run it per minute.

And that’s it. Once you have everything, your AI bot will be configured and you will be able to use it within the limits of the API. You will have the bot on Telegram, but you will be able to change the AI ​​model it uses directly from Make.

In Xataka Basics | How to create an excel with artificial intelligence where you can add the expenses of your digital purchase receipts

Leave your vote

Leave a Comment

GIPHY App Key not set. Please check settings

Log In

Forgot password?

Forgot password?

Enter your account data and we will send you a link to reset your password.

Your password reset link appears to be invalid or expired.

Log in

Privacy Policy

Add to Collection

No Collections

Here you'll find all collections you've created before.