Introduction
Modern AI agents can perform dozens of tasks: from sending emails to managing chats. But often, connecting each service — Gmail, Telegram, Slack, or Trello — requires separate settings, tokens, and API keys. This slows down development and increases the risk of errors. The solution is a universal credential connector that unifies all services through a single interface. In this article, I will show you how to connect Gmail and Telegram to an AI agent in 10 minutes using standard credentials, and how this simplifies automation.
What is a Universal Credential Connector and Why Do You Need It?
A credential connector is a software bridge between an AI agent and external services. Instead of writing separate code for each API, you configure one module that stores and manages access keys (tokens, passwords, OAuth secrets). Advantages:
- Centralization — all credentials in one place.
- Security — automatic encryption and key rotation.
- Flexibility — easy to add a new service without rewriting the agent.
Step 1: Preparing Credentials for Gmail
For the AI to read and send emails, access to the Google API is required. Here's how to set it up:
- Create a project in Google Cloud Console
- Go to console.cloud.google.com
-
Click "Create Project" and give it a name (e.g., "AI-Agent-Gmail").
-
Enable the Gmail API
- In the menu, select "APIs & Services" → "Library".
-
Find "Gmail API" and click "Enable".
-
Set up OAuth 2.0 credentials
- Go to "Credentials" → "Create Credentials" → "OAuth client ID".
- Choose "Web application" as the type and specify the redirect URI (e.g.,
http://localhost:8080for testing). -
Copy the Client ID and Client Secret.
-
Generate an access token
- Use a library (e.g.,
google-authfor Python) to obtain a refresh token. - Example command:
gcloud auth application-default login.
Now you have credentials: Client ID, Client Secret, and Refresh Token. Save them in a secure storage.
Step 2: Setting Up Telegram via BotFather
Telegram bots do not require OAuth; an API token is sufficient. Algorithm:
- Create a bot
- Open Telegram and find
@BotFather. - Send the command
/newbotand follow the instructions. -
After creation, you will receive an API Token (e.g.,
123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11). -
Configure permissions
- In BotFather, select
/mybots→ your bot → "Bot Settings" → "Group Privacy" → disable it so the bot can see all messages. -
To read notifications, add the bot to the necessary chats.
-
Verify access
- Send the bot the
/startcommand — it should respond.
Credentials for Telegram are simply the token itself.
Step 3: Integration via a Unified Connector
Now, combine both sets of credentials in one place. For example, let's take an open-source solution — Connector Hub (an analog may be built into your platform, e.g., asibiont.com).
- Install the connector
- If using Python:
pip install connector-hub. -
Or add the module to your project.
-
Create a configuration file (e.g.,
config.json):
json { "services": { "gmail": { "client_id": "your-client-id", "client_secret": "your-client-secret", "refresh_token": "your-refresh-token" }, "telegram": { "api_token": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11" } } } -
Connect the AI agent
- Import the connector and pass the credentials:
```python
from connector_hub import Connector
connector = Connector('config.json')
# Now you can call methods:
# connect
Conclusion
By using a unified credential connector, you can significantly simplify the process of connecting multiple services to an AI agent. This approach not only saves time but also enhances security and maintainability. Start integrating your Gmail and Telegram today and unlock the full potential of your AI automation.
Comments