Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Object Storage
    • All tutorials
    • Getting statistics on object queries with S3 Select
    • Getting website traffic statistics with S3 Select
    • Getting statistics on object queries using Yandex Query
    • Cost analysis by resource
    • Server-side encryption
    • Blue-green and canary deployment of service versions
    • Analyzing logs in DataLens
    • Mounting buckets to Yandex Data Processing host filesystems
    • Using Object Storage in Yandex Data Processing
    • Importing, processing, and exporting Object Storage data to Managed Service for ClickHouse®
    • Connecting a bucket as a disk in Windows
    • Migrating data from Yandex Data Streams using Yandex Data Transfer
    • Using hybrid storage in Yandex Managed Service for ClickHouse®
    • Loading data from Yandex Managed Service for OpenSearch to Yandex Object Storage using Yandex Data Transfer
    • Automatically copying objects from one bucket to another
    • Regular asynchronous recognition of audio files in a bucket
    • Training a model in Yandex DataSphere on data from Object Storage
    • Connecting to Object Storage from VPC
    • Migrating data to Yandex Managed Service for PostgreSQL using Yandex Data Transfer
    • Uploading data to Yandex MPP Analytics for PostgreSQL using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for ClickHouse® using Yandex Data Transfer
    • Uploading data to Yandex Managed Service for YDB using Yandex Data Transfer
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Uploading data from Yandex Managed Service for YDB using Yandex Data Transfer
    • Hosting a static Gatsby website in Object Storage
    • Installing WordPress High Availability using Cloud Apps
    • Installing WordPress using Cloud Apps
    • Installing Ghost CMS High Availability using Cloud Apps
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Exchanging data between Yandex Managed Service for ClickHouse® and Yandex Data Processing
    • Importing data from Yandex Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Importing data from Yandex Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Migrating data from Yandex Object Storage to Yandex Managed Service for MySQL® using Yandex Data Transfer
    • Migrating a database from Yandex Managed Service for MySQL® to Yandex Object Storage
    • Exporting Greenplum® data to a cold storage in Yandex Object Storage
    • Loading data from Yandex Direct to a Yandex Managed Service for ClickHouse® data mart using Yandex Cloud Functions, Yandex Object Storage, and Yandex Data Transfer
    • Uploading Terraform states to Object Storage
    • Locking Terraform states using Managed Service for YDB
    • Visualizing Yandex Query data
    • Publishing game updates
    • Developing a custom integration in API Gateway
    • Storing application runtime logs
    • Building a skill for Alice and a website with authorization
    • Building an interactive serverless application using WebSocket
    • Deploying a web application using the Java Servlet API
      • Overview
      • Management console
      • Terraform
    • Replicating logs to Object Storage using Fluent Bit
    • Replicating logs to Object Storage using Data Streams
    • Uploading audit logs to ArcSight SIEM
    • Uploading audit logs to Splunk SIEM
    • Creating an MLFlow server for logging experiments and artifacts
    • Operations with data in Yandex Query
    • Federated data queries using Query
    • Recognizing text in image archives using Vision OCR
    • Scheduled image and PDF recognition in an Object Storage bucket
    • Automating tasks using Managed Service for Apache Airflow™
    • Processing files with usage details in Yandex Cloud Billing
    • Deploying a web app with JWT authorization in API Gateway and Firebase authentication
    • Searching for Yandex Cloud events in Yandex Query
    • Searching for Yandex Cloud events in Object Storage
    • Creating an external table from a bucket table using a configuration file
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
    • Using Object Storage in Yandex Managed Service for Apache Spark™
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Bucket logs
  • Release notes
  • FAQ

In this article:

  • Get your cloud ready
  • Required paid resources
  • Set up the required resources
  • Create a Telegram bot
  • Post a bot image
  • Create an Object Storage bucket
  • Upload the image to the bucket
  • Get a link to the uploaded image
  • Create an API gateway
  • Create a function
  • Configure a link between the function and the Telegram bot
  • Test your Telegram bot
  • How to delete the resources you created
  1. Tutorials
  2. Developing a Telegram bot
  3. Management console

How to create a Telegram bot using Serverless in the management console

Written by
Yandex Cloud
Updated at June 17, 2026
  • Get your cloud ready
    • Required paid resources
  • Set up the required resources
  • Create a Telegram bot
  • Post a bot image
    • Create an Object Storage bucket
    • Upload the image to the bucket
    • Get a link to the uploaded image
  • Create an API gateway
  • Create a function
  • Configure a link between the function and the Telegram bot
  • Test your Telegram bot
  • How to delete the resources you created

To create a Telegram bot using Serverless in the Yandex Cloud management console:

  1. Get your cloud ready.
  2. Set up required resources.
  3. Register your Telegram bot.
  4. Post a bot image.
  5. Create an API gateway.
  6. Create a function.
  7. Configure a link between the function and the Telegram bot.
  8. Test your Telegram bot.

If you no longer need the resources you created, delete them.

Get your cloud readyGet your cloud ready

Sign up for Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or create a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page.

Learn more about clouds and folders here.

Required paid resourcesRequired paid resources

The cost of supporting the Telegram bot infrastructure includes:

  • Fee for function calls, computing resources allocated for the function, and outgoing traffic (see Cloud Functions pricing).
  • Fee for data storage in Object Storage, operations with data, and outgoing traffic (see Object Storage pricing).
  • Fee for the number of requests to the API gateway and outgoing traffic (see Yandex API Gateway pricing).

Set up the required resourcesSet up the required resources

  1. Download an image for the bot.
  2. Create a service account and assign it the editor and functions.functionInvoker roles for your folder.

Create a Telegram botCreate a Telegram bot

Create a bot in Telegram and get a token.

  1. To register a new bot, start BotFather and run the below command.

    /newbot
    
  2. In the name field, enter a name for the bot, e.g., Serverless Hello Telegram Bot. This is the name users will see when chatting with the bot.

  3. In the username field, specify a username for the bot, e.g., ServerlessHelloTelegramBot. You can use it to find the bot in Telegram. The username must end with ...Bot or ..._bot.

    As a result, you will get a token. Save it, as you will need it later.

  4. Set an icon for the bot using sayhello.png from the saved archive. Send this command to BotFather:

    /setuserpic
    

Post a bot imagePost a bot image

If you want your bot to respond to user messages with an image, create an Object Storage bucket and upload sayhello.png from the saved archive to it.

Create an Object Storage bucketCreate an Object Storage bucket

Management console
  1. In the management console, select the folder where you want to create a bucket.

  2. Go to Object Storage.

  3. Click Create bucket.

  4. On the bucket creation page:

    1. Enter a name for the bucket. Save the bucket name. You will need it later.

    2. Specify these bucket settings:

      • Max size: 1 GB.
      • Read objects: For all.
      • Storage class: Standard.
    3. Click Create bucket.

Upload the image to the bucketUpload the image to the bucket

Management console
  1. In the management console, select the folder containing the created bucket.
  2. Go to Object Storage.
  3. Select the bucket.
  4. Click Upload.
  5. In the window that opens, select sayhello.png from the saved archive. The management console will display the file selected for upload.
  6. Click Upload.

Get a link to the uploaded imageGet a link to the uploaded image

Management console
  1. In the management console, select the folder containing the created bucket.
  2. Go to Object Storage.
  3. Select the bucket.
  4. Select sayhello.png.
  5. Click Get link.
  6. Make sure the image is accessible through the link in your browser.

Create an API gatewayCreate an API gateway

To enable your bot to work with a function, create and configure an API gateway.

Management console
  1. In the management console, select the folder where you want to create an API gateway.

  2. Go to API Gateway.

  3. Click Create API gateway.

  4. Name the gateway: for-serverless-hello-telegram-bot.

  5. Clear the Specification field and paste this code:

    openapi: 3.0.0
    info:
      title: for-serverless-hello-telegram-bot
      version: 1.0.0
    paths:
      /sayhello.png:
        get:
          x-yc-apigateway-integration:
            type: object_storage
            bucket: <bucket_name>
            object: sayhello.png
            presigned_redirect: false
            service_account_id: <service_account_ID>
          operationId: static
    

    Where:

    • bucket: Bucket name.
    • service_account_id: ID of the service account you created when setting up the resources.
  6. Click Create.

  7. Select the previously created API gateway. Save the Default domain field value as you will need it to create the function.

Create a functionCreate a function

If you want your Telegram bot to respond to the /start and /help commands and send an image in response to any other text, create a designated function.

Management console
  1. In the management console, select the folder where you want to create a function.

  2. Go to Cloud Functions.

  3. Click Create function.

  4. Enter the function name: fshtb-function.

  5. Click Create.

  6. Under Editor, select Node.js as the runtime environment and click Continue.

  7. Under Function code, replace the contents of the index.js file with the code below. Replace <API_gateway_domain> with the API gateway service domain.

    const { Telegraf } = require('telegraf');
    
    const bot = new Telegraf(process.env.BOT_TOKEN);
    bot.start((ctx) => ctx.reply(`Hello. \nMy name Serverless Hello Telegram Bot \nI'm working on Cloud Function in the Yandex Cloud.`))
    bot.help((ctx) => ctx.reply(`Hello, ${ctx.message.from.username}.\nI can say Hello and nothing more`))
    bot.on('text', (ctx) => {
        ctx.replyWithPhoto({url: '<API_gateway_domain>/sayhello.png'});
        ctx.reply(`Hello, ${ctx.message.from.username}`);
    
    });
    
    module.exports.handler = async function (event, context) {
        const message = JSON.parse(event.body);
        await bot.handleUpdate(message);
        return {
            statusCode: 200,
            body: '',
        };
    };
    
  8. Under Function code, create a file named package.json and paste the following code into it:

    {
      "name": "ycf-telegram-example",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "MIT",
      "dependencies": {
        "telegraf": "^4.12.0"
      }
    }
    
  9. Specify the following parameters:

    • Runtime environment: nodejs22.
    • Entry point: index.handler.
    • Timeout: 5.
  10. Add the BOT_TOKEN environment variable. In the Value field, specify the Telegram bot token.

  11. Click Save changes.

  12. Make sure the function is public. To do this, navigate to the Overview page and enable General information under Public function.

  13. Save your function ID, as you will need it later.

Configure a link between the function and the Telegram botConfigure a link between the function and the Telegram bot

  1. Update the API gateway specification:

    Management console
    1. In the management console, select a folder.

    2. Go to API Gateway.

    3. Select the for-serverless-hello-telegram-bot API gateway.

    4. Update the API gateway specification by adding the fshtb-function section at the end of the code:

        /fshtb-function:
          post:
            x-yc-apigateway-integration:
              type: cloud_functions
              function_id: <function_ID>
            operationId: fshtb-function
      

      Where function_id is the fshtb-function ID.

    5. Click Save.

  2. In the terminal, run the following command, with <bot_token> replaced with your Telegram bot token, and <API_gateway_domain>, with a link to your API gateway's service domain:

    • Linux, macOS:

      curl \
        --request POST \
        --url https://api.telegram.org/bot<bot_token>/setWebhook \
        --header 'content-type: application/json' \
        --data '{"url": "<API_gateway_domain>/fshtb-function"}'
      
    • Windows (cmd):

      curl ^
        --request POST ^
        --url https://api.telegram.org/bot<bot_token>/setWebhook ^
        --header "content-type: application/json" ^
        --data "{\"url\": \"<API_gateway_domain>/fshtb-function\"}"
      
    • Windows (PowerShell):

      curl.exe `
        --request POST `
        --url https://api.telegram.org/bot<bot_token>/setWebhook `
        --header '"content-type: application/json"' `
        --data '"{ \"url\": \"<API_gateway_domain>/fshtb-function\" }"'
      

    Result:

    {"ok":true,"result":true,"description":"Webhook was set"}
    

    Where:

    • <bot_token>: Telegram bot token.
    • <API_gateway_domain>: API gateway service domain.

    Result:

    {"ok":true,"result":true,"description":"Webhook was set"}
    

Test your Telegram botTest your Telegram bot

Chat with the bot:

  1. Open Telegram and search for the bot using the previously created username.

  2. Send /start to the chat.

    The bot should respond with:

    Hello.
    My name Serverless Hello Telegram Bot
    I'm working on Cloud Function in the Yandex Cloud.
    
  3. Send /help to the chat.

    The bot should respond with:

    Hello, <username>.
    I can say Hello and nothing more
    
  4. Send a text message to the chat. The bot should respond with an image and this message: Hello, <username>.

How to delete the resources you createdHow to delete the resources you created

To stop paying for the resources you created:

  1. Delete the function.
  2. Delete the API gateway.
  3. Delete the bucket.

See alsoSee also

  • How to create a Telegram bot using Serverless and Terraform

Was the article helpful?

Previous
Overview
Next
Terraform
© 2026 Direct Cursus Technology L.L.C.