Subscribe to our Blog

Subscribe to Crossmint's blog to receive updates on the latest case studies, Web3 technical guides, and more.

Subscribe Crossmint Blog cover image
Dwight Torculas profile image Dwight Torculas

How to Create a Telegram Ecommerce Bot

Learn how to build a Telegram ecommerce bot in 10 minutes. Create AI-powered shopping assistants that sell products through simple chat messages. Step-by-step guide with code examples.

How to Create a Telegram Ecommerce Bot

Imagine selling products through Telegram with just a simple conversation. No websites, no complicated checkout flows—just messages that convert into sales.

That's the power of agentic commerce. Your customers type "Find me wireless headphones under $50," and your bot handles everything: product search, recommendations, and instant purchase completion.

This guide will show you how to build your own Telegram ecommerce bot that can tap into millions of products from Amazon, Shopify, and other major retailers.

The Github repo for the Telegram Ecommerce Bot can be found here.

Features of the Telegram Ecommerce Bot

  • AI Chat: GPT-4o powered conversations
  • Product Search: Amazon product search with instant results
  • Crossmint Wallets: Client-side wallet creation with passkey signers
  • Delegation: Enable fast shopping with automatic transaction signing
  • Secure Payments: USDC payments on Base Sepolia testnet
  • Web Interface: Next.js app for wallet management and delegation

Prerequisites

  • Node.js 18+
  • npm or yarn
  • ngrok account (for local development)
  • Telegram Bot Token (from @BotFather)
    • Message @BotFather on Telegram
    • Create new bot: /newbot
    • Follow prompts and save your bot token
  • OpenAI API Key
  • Crossmint API Keys (staging environment)
    • Sign up at Crossmint Console
    • Create new project
    • Get both Server API Key and Client API Key (use scopes below)
    • Use staging environment for development
  • SearchAPI.io Key (for Amazon product search)

Crossmint API Scopes

For this Telegram bot, we will be using Crossmint's agentic finance platform to create wallets and enable the bot to make purchases. When creating your Crossmint API keys, ensure you enable the following scopes:

Server-side API Key Scopes:

  • wallets.read
  • wallets:transactions.create
  • wallets:transactions.read
  • wallets:transactions.sign
  • orders.create
  • orders.read
  • orders.update

Client-side API Key Scopes:

  • wallets.read
  • wallets.create
  • orders.create

You can configure API keys and scopes in your Crossmint dashboard under Project Settings > API Keys.

💨 Quick Setup

1. Clone and Install

git clone <your-repo-url>
cd telegram-agent
npm install
cd web-interface && npm install && cd ..

2. Quick Setup

npm run setup

This will:

  • Copy .env.example to .env
  • Copy web-interface/.env.example to web-interface/.env.local
  • Show setup completion message

ngrok Setup for Local Development

Telegram API sometimes may give a hard time working with http URLs, so we need ngrok to tunnel localhost.

1. Install ngrok

npm install -g ngrok

2. Configure ngrok Account

ngrok config add-authtoken YOUR_NGROK_AUTHTOKEN

3. Start ngrok Tunnels

We've included a ngrok.yml configuration file. Start both tunnels:

# Start ngrok with our configuration
ngrok start --all --config ngrok.yml

This will create two tunnels:

  • Bot Serverhttps://abc123.ngrok.io → localhost:3000
  • Web Interface: https://def456.ngrok.io → localhost:3001

4. Update Environment Variables

Copy the ngrok URLs and update your environment files:

Main .env :

WEB_APP_URL=https://def456.ngrok.io  # Web interface ngrok URL

Web Interface .env.local :

NEXT_PUBLIC_BOT_API_URL=https://abc123.ngrok.io  # Bot server ngrok URL
BOT_WEBHOOK_URL=https://abc123.ngrok.io/api/webhook/wallet-created
NEXTAUTH_URL=https://def456.ngrok.io  # Web interface ngrok URL

Start the Application

npm run dev:all

This starts:

  • 🤖 Bot Server on localhost:3000
  • 🌐 Web Interface on localhost:3001

Test the Setup

1. Test Bot Connection

  1. Find your bot on Telegram (search for your bot's username)
  2. Send /start command
  3. You should get a welcome message

/search wireless headphones

You should see Amazon products with "Buy with Crossmint" buttons.

3. Test Wallet Creation

  1. Click any "Buy with Crossmint" button
  2. Should redirect to web interface for wallet creation
  3. Complete wallet setup with email/passkey

Key Features Walkthrough

1. AI Chat

  • Send any message to the bot
  • Powered by GPT-4o via Vercel AI SDK
  • Maintains conversation context

/search [product name]
  • Searches Amazon products via SearchAPI.io
  • Shows product cards with images and prices
  • "Buy with Crossmint" buttons for each product

3. Wallet Management

/login    # Create/connect Crossmint wallet
/balance  # Check wallet balance
/topup    # Add funds to wallet
/logout   # Sign out and clear session

5. Memory & Preferences

/memory   # See conversation history
/forget   # Clear conversation history

Voilà - if you've made it this far, congratulations on getting your Telegram Ecommerce Bot set up!

For notes on security, troubleshooting or ways to contribute, go to the Github repo.

The Agentic Finance Platform for AI Agent Companies

If you’re an AI agent company looking to launch fast with enterprise-grade payments infrastructure for agentic finance and no vendor lock-in, Crossmint's Agentic Finance platform is perfect for you. Our all-in-one solution for AI agent companies includes:

  1. AI Agent Wallets: Non-custodial wallets with programmable guardrails that enable agents to manage assets securely, maintain accountability through public transaction records, and operate within configured spending limits.
  2. World Store: An API service giving agents access to over 1 billion SKUs of real-world goods and services, with support for payments using major tokens across 40+ chains.
  3. GOAT SDK: An open-source library offering 250+ onchain actions across 40+ blockchains, allowing agents to send stablecoins, swap tokens, and create DeFi positions with MIT license and support for major frameworks.
  4. Credentials: Tools to authorize agents to act on users' behalf securely.

If you’re an AI agent company and want to learn more, reach out to us here!