How to create a Telegram bot that sends you a summary made by Gemini of each email you receive in Gmail and other emails

Let’s explain to you how to create a Telegram bot that sends you a summary of your emails emails, such as Gmail. Thus, when you receive a new email, whether from anyone or from specific senders or topics, an artificial intelligence will make a summary and send it to you. All this without knowing how to program nor have technical knowledge.

This is not something you can do simply by asking artificial intelligence, and we are going to need a program that generates workflows or work flows. We will use Make.com, because it is very complete and easy to use. Besides, Make.com It has a free version that is perfect for taking the first steps, although with some limitations.

In Make we will have to link any artificial intelligence, although we have opted for Gemini because it is easy to obtain a free API for it. And then, We have chosen Telegram because creating bots is easyand it only takes a few minutes.

In the end, what you will need is an API from an AI, a Token key from a Telegram bot, and creating the workflow chain on Make.com. In the examples we have used Gmail because it is also easy to link to it.

Get your Gemini API first

Create API
Create API

The first thing we are going to do is get a google api to be able to use Gemini in our project. For that, 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.

API Options
API Options

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 Gmail Gemini. 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–“.

Set up the Telegram bot

Create bot
Create bot

The first thing you have to do is create a bot on Telegram. For that you have to look for the “@BotFather” tool and write to it as if it were a new user. Use the /newbot command to create a new bot, giving it 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.

Start creating your project

Create from scratch
Create from scratch

Now you have to go to Make.com and click on the option Create new scenario to create a new project. In the options choose the option Build from scratch to create an automation from scratch.

From what we are going to do, you must understand that we will create an automation of several modules, each one of them different. These automations will form a chainso that the action of the first leads to the second, and that of the second to the third. Come on, the order in which we put them is important.

Add your email module as a trigger

Choose Gmail
Choose Gmail

You will go to a blank screen with a button with the plus symbol. Here, click on the + button and from the drop-down menu choose Gmail. Inside now click on the option Watch emails to configure the action of reading your emails. This will cause your automation to be activated every time you receive an email in Gmail. It is a trigger, which is the element that will start this automation.

Set up Gmail
Set up Gmail

Now click on the button Create a connectionwhich will open a screen where you have to name the connection at the top, and at the bottom log in with your Gmail account to link it. You will have to log in and give the website permissions to access your email.

Setting 1
Setting 1

Once the action has been added, you can filter the type of emails that this automation executes. Can choose emails from a specific folder or labelas well as other criteria, so that these are launched and read by the AI. You can also set some limits.

This screen gives you the possibility to fully customize the experience depending on What type of emails do you want the AI ​​to summarize for you?. It is an important step, especially because you will be able to make it only perform this action with certain types of emails. For example, they can be from senders related to your work or a specific project.

If you open the advanced settings either Advanced settingsyou can specify even more. For example, you can configure so that only runs with emails from a certain senderwith a certain subject, and many other characteristics.

since when
since when

Now you can configure from what moment do you want the data to be processed. For example, you can choose From now on so that they are processed from the emails you start receiving from now on.

Mail
Mail

You can also link other emails. For this, instead of the Gmail module you can use the Email module, which will allow you to connect with Google, with Microsoft for Outlook, or with others through IMAP. Outlook also has its own module.

Now add the Gemini module

Generate response
Generate response

Now it’s time to add the second module. To do this, click on the + button to the right of Gmail, and on the screen that opens choose the option Gemini. In the options that appear in the module that opens, choose where to put Generate a response.

Gemini
Gemini

This will now open a key module, where you simply have to write the Gemini API Key that we have generated at the beginning of this tutorial. It is important that the Gemini module is the module that is after Gmail, because we will be creating a chain.

Gemini Module
Gemini Module

Now you have to configure the Gemini module configuration screen. Here, you first have to choose the module you want to use. For such a simple task, you don’t need the most modern one, so it depends on what you want. Then further down messages you have to create Item 1.

Whom Role you have to put Userand below go to Partsand in Item 1 put the option text as Message Typeto send a text message. And below, where it says text you have to add the prompt What are you going to send to Gemini?

The prompt I used is “Summarize the following email in less than a hundred words. Focus on the main points of the content, and ignore signatures and disclaimers. Be clear and concise. You need to say who sent the email, the subject and the summary of the content. Here below is the content:”

Then, along with the prompt you have to choose several of the labels or options that are automatically displayed on the screen on the left when you are writing. These labels are used to specify the Gmail content you attach to the Gemini prompt. We have chosen those of From (name) so that the sender name is sent, From (email) for the email address to be sent, Subject to include the subject, and Full text body so that the body of the email is sent to Gemini. When you have it, save it.

Add the Telegram module

Telegram module
Telegram module

Next we will add the Telegram module, so that once the content of the email is sent to Gemini, from Gemini it goes to Telegram. To do this, click on + and choose the option Telegram Bot. In Telegram Bot options, choose the option Send a Text Message or a Replywhich means that Telegram will send us a message.

Create a connection
Create a connection

A screen will open where you have to click on Create a connection. You will have to give the connection a name, for example the name of the bot, and then add the token that Bot Father gave us when creating a bot specific for this task.

Set up Telegram
Set up Telegram

Now we have to configure the response of the Telegram bot. For that, once the connection is created you have to add Chat IDand then you have to write the text that will be sent to you in the message. You can put an introduction, but then you have to add the option Result from the left column.

You will see that two-color commands now appear in the left column. This is because one color is for adding content from the Gemini module and the other for Gmail. Here, we choose Result of the Gemini module so that give us the result of the prompt that we gave in your module configuration.

To obtain the Chat IDyou have to enter the website https://api.telegram.org/bot/getUpdateschanging by the token you are using on Telegram. This will open a page with a code, where you have to search for the term chatafter which there will be go”: followed by some numbers. These numbers are the Chat ID.

Now test and program the automation

Proof
Proof

Once everything is configured, on the main automation screen press the button Run elevenwhich is good to try it once. You will see how up in the chain of the three modules those that carry out the task satisfactorily turn green. In the end, all the steps should be green and you should receive the Telegram message. If there is a fault, the corresponding step will appear in red.

Message
Message

If everything is fine and the message with the summary has arrived, then next to Run eleven can activate the option Every 15 minutes. This will activate the automation, so that every 15 minutes it checks if you have received an email with the characteristics that you have configured to start processing and send you the summary.

a little trick What you can do is that when you configure the Gmail module, first set the condition that the email that arrives be from a certain sender, and that you set another email account of yours.

This will make testing easier because you can write to yourself so you always have new email to process. And once everything is fine, then you configure it for the senders you want or for it to act on any email you receive.

In Xataka Basics | What is Claude Cowork, how it works, and what things you can do with this AI assistant on your computer

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.