Crypto.com AI Agent SDK
  • Getting Started
    • Introduction
    • Quick Start Guide: Simulation Entry Point
  • Core Concepts Overview
    • Plugins
    • Tools
    • Blockchain Functions
      • Wallet Management
      • Token Interaction
      • Transaction Queries
      • Block Information
      • Contract Operations
      • CronosID Operations
      • Defi Operations
      • Crypto.com Exchange
    • Built-in Telegram Feature
    • Advanced Usage: Custom Instructions
    • Dynamic AI Model Manager
  • Crypto.com On-Chain Developer Platform
    • Developer Platform API Methods
  • On-Chain Functions and Examples
    • AI Agent Chatbot
    • "Magic Link" Signer
  • Resources for Developers
Powered by GitBook
On this page
  • Introduction
  • Prerequisites
  • Get a Telegram Bot Token
  • Telegram Plugin
  • Run everything
  • Troubleshooting

Was this helpful?

  1. Core Concepts Overview

Built-in Telegram Feature

PreviousCrypto.com ExchangeNextAdvanced Usage: Custom Instructions

Last updated 1 day ago

Was this helpful?

Introduction

AI Agent SDK has a plugin mode and one of the initial plugins is the Telegram plugin, which allows users to connect the agent to their Telegram bot with just a few lines of code.

This guide demonstrates how to build a Telegram bot that interacts with the Cronos network. The bot enables users to query blockchain information and execute transactions smoothly.

A video demo is avaliable in .

Prerequisites

  • Python installed (version >= 3.12)

Get a Telegram Bot Token

  • Open Telegram and search for @BotFather.

  • Type /start and /newbot, then follow the prompts to name your bot (must end in bot, e.g., CryptoHelper).

  • After creation, @BotFather will give you a TOKEN (e.g., 7008008900:AAEKe6vIwM0gokw..), which should be safely kept.

Telegram Plugin

We need to add telegram plugin when initializing the Agent:

import os
from crypto_com_agent_client import Agent
from dotenv import load_dotenv

load_dotenv()

# Initialize the agent with LLM and blockchain configurations
# Current chainID refers to Cronos zkEVM Testnet, optionally change it to other Cronos networks
agent = Agent.init(
   llm_config={
       "provider": "OpenAI",
       "model": "gpt-4o-mini",
       "provider-api-key": os.getenv("OPENAI_API_KEY"),
       "temperature": "float-controlling-output-randomness",
   },
   blockchain_config={
       "chainId": "240", 
       "explorer-api-key": os.getenv("EXPLORER_API_KEY"),
       "private-key": os.getenv("PRIVATE_KEY"),
       "sso-wallet-url": "your-sso-wallet-url",
   },
   plugins={
       "instructions": "You are a humorous assistant that always includes a joke in your responses.",
       "telegram": {"bot_token": os.getenv("TELEGRAM_BOT_TOKEN")},
   },
)

agent.start_telegram()
import os
from crypto_com_agent_client import Agent
from dotenv import load_dotenv
​
load_dotenv()
​
# Initialize the agent with LLM and blockchain configurations
# Current chainID refers to Cronos zkEVM Testnet, optionally change it to other Cronos networks
agent = Agent.init(
  llm_config={
      "provider": "GoogleGenAI",
      "model": "gemini-2.0-flash",
      "provider-api-key": os.getenv("GEMINI_API_KEY"),
      "temperature": "float-controlling-output-randomness",
  },
  blockchain_config={
      "chainId": "240",
      "explorer-api-key": os.getenv("EXPLORER_API_KEY"),
      "private-key": os.getenv("PRIVATE_KEY"),
      "sso-wallet-url": "your-sso-wallet-url",
  },
  plugins={
      "instructions": "You are a humorous assistant that always includes a joke in your responses.",
      "telegram": {"bot_token": os.getenv("TELEGRAM_BOT_TOKEN")},
  },
)
​
agent.start_telegram()

Run everything

As shown in the example code, we start the Telegram bot by invoking the Agent's built-in function:

agent.start_telegram()

Once the bot is running, test it to ensure it’s working as expected:

  • Open Telegram and search for your bot using the bot name you set up with @BotFather.

  • Send a sample command or message, such as /start, to see if the bot responds.

Troubleshooting

If you encounter issues during setup or execution, follow these tips:

  • Check your API keys to ensure they are correctly set in the environment variables.

  • Verify dependencies by confirming that all packages in requirements.txt are installed.

  • Review Telegram Bot API limitations to ensure compliance with rate limits and usage guidelines.

installed.

API Key for or

API Keys of AI provider, refer to the to see which providers are supported by the AI Agent SDK.

Required account: .

Crypto.com AI Agent SDK
Cronos EVM Blockchain Explorer
Cronos zkEVM Blockchain Explorer
Dynamic AI Model Manager
Telegram Bot Token
Crypto.com AI Agent SDK X post