{"id":15199949,"url":"https://github.com/harnyk/tgvercel","last_synced_at":"2026-01-27T08:06:32.779Z","repository":{"id":240536517,"uuid":"802889334","full_name":"harnyk/tgvercel","owner":"harnyk","description":"Run telegram bot on Vercel easily (as well as locally)","archived":false,"fork":false,"pushed_at":"2024-12-02T15:08:21.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T14:43:28.568Z","etag":null,"topics":["go","golang","telegram","telegram-bot","telegram-bot-api","vercel"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harnyk.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-19T14:43:05.000Z","updated_at":"2024-12-02T15:07:36.000Z","dependencies_parsed_at":"2024-09-24T02:01:12.903Z","dependency_job_id":null,"html_url":"https://github.com/harnyk/tgvercel","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"5668e4b3b3a236af6384ded39791f1b793d67288"},"previous_names":["harnyk/tgvercel"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/harnyk/tgvercel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harnyk%2Ftgvercel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harnyk%2Ftgvercel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harnyk%2Ftgvercel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harnyk%2Ftgvercel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harnyk","download_url":"https://codeload.github.com/harnyk/tgvercel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harnyk%2Ftgvercel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28809344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","telegram","telegram-bot","telegram-bot-api","vercel"],"created_at":"2024-09-28T02:22:13.069Z","updated_at":"2026-01-27T08:06:32.755Z","avatar_url":"https://github.com/harnyk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tgvercel\n\n`tgvercel` is a tool for easing the setup of Telegram bot in Vercel.\n\n## What is it for?\n\nSo you want to create a telegram bot and host it on Vercel for free.\nEver feeld frustrated by the necessity of setting up a Telegram bot webhook?\n\n`tgvercel` and its optional companion library (https://github.com/harnyk/tgvercelbot) automates this process for you making it as easy as possible.\n\nFor each fresh deployment of your Vercel project, `tgvercel` will:\n\n-   get a URL of deployment\n-   get a Telegram token and webhook secret from the environment variables stored in your Vercel project settings, corresponding to the target (production, or preview)\n-   use Telegram API to set up the webhook to your Vercel project's function which will receive updates from Telegram at the specific deployment URL\n\nBesides that, `tgvercel` also provides a CLI command to set the environment variables in the Vercel project.\n\nOn its turn, `tgvercelbot` allows to easily create a Vercel cloud function which would handle all the updates from Telegram. Feel free to browse its documentation [here](https://github.com/harnyk/tgvercelbot).\n\n## Installation\n\nIf you have Go installed, you can call the following command to install `tgvercel`:\n\n```bash\ngo install github.com/harnyk/tgvercel@latest\n```\n\nOr you can just run `tgvercel` directly:\n\n```bash\ngo run github.com/harnyk/tgvercel@latest [arguments]\n```\n\nAnother option is to install one of the pre-compiled binaries from the [Release](https://github.com/harnyk/tgvercel/releases) page.\n\nIf you have [`eget`](https://github.com/zyedidia/eget), the installation is as easy as:\n\n```bash\neget harnyk/tgvercel\n```\n\n## Usage\n\n### Step 1. Init the secrets\n\nSuppose, you have created a Vercel project and a couple of Telegram bots (one for `preview` and one for `production`). You know the Telegram bot token and you are in the directory of the project (so `.vercel/project.json` is in the current directory). Also you are authenticated with Vercel CLI.\n\nIn order to initialize the `preview` environment, you can run:\n\n```bash\ntgvercel init --target=preview --telegram-token=YOUR_PREVIEW_TELEGRAM_TOKEN\n```\n\nThen, do the same for `production` environment:\n\n```bash\ntgvercel init --target=production --telegram-token=YOUR_PRODUCTION_TELEGRAM_TOKEN\n```\n\nThis will create a pair of environment variables for each target environment. The variables created are:\n\n-   `TELEGRAM_TOKEN` - Telegram bot token, the one that you provided.\n-   `TELEGRAM_WEBHOOK_SECRET` - Telegram bot webhook secret, generated automatically. This is a `?secret=` part of the URL of the webhook, protecting the endpoint from unauthorized requests.\n\n### Step 2. Create a Telegram bot endpoint\n\nYou can create an endpoint in any language, supported by Vercel. But if you want to write it in Go, you can use a conventional library [tgvercelbot](https://github.com/harnyk/tgvercelbot) which allows you to integrate telegram-bot-api with Vercel runtime easily.\n\nCreate a handler in `api/tg/webhook.go` with the following code:\n\n```go\npackage handler\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/harnyk/tgvercelbot\"\n    tgbotapi \"github.com/go-telegram-bot-api/telegram-bot-api/v5\"\n)\n\nvar tgv = tgvercelbot.New(tgvercelbot.DefaultOptions())\n\nfunc WebhookHandler(w http.ResponseWriter, r *http.Request) {\n\ttgv.HandleWebhook(r, func(bot *tgbotapi.BotAPI, update *tgbotapi.Update) {\n        if update.Message != nil {\n            // do something, for example, echo:\n            bot.Send(tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text))\n        }\n    })\n}\n```\n\n### Step 3. Setup Telegram webhook\n\nFirst of all, you have to deploy the project and get the URL of the deployment.\n\n**Fun fact:** `vercel` command outputs the URL of the deployment to stdout, so you can save it to a variable.\n\n```bash\n# Deploy the project and get the URL of the deployment\nDEPLOYMENT_URL=$(vercel)\n```\n\nThen, you can call `tgvercel hook` command with the following arguments:\n\n```bash\n# Tell Telegram to send updates to the URL of the deployment:\ntgvercel hook $DEPLOYMENT_URL /api/tg/webhook\n```\n\nHere, `/api/tg/webhook` is the route that we created in the previous step. It may differ in your case, so you always have to specify it.\n\nThe following oneliner will do the same thing as the previous two commands:\n\n```bash\ntgvercel hook $(vercel) /api/tg/webhook\n```\n\nIf you want to deploy to production, just add the `--prod` flag to the `vercel` command, as you would normally do:\n\n```bash\ntgvercel hook $(vercel --prod) /api/tg/webhook`\n```\n\n## Commands Reference\n\n### Init\n\n-   `tgvercel init \u003cprojectIdOrName\u003e`: set the environment variables in the Vercel project\n\nArguments:\n\n-   `\u003cprojectIdOrName\u003e, optional`: Project ID or name, if not specified, the project ID will be taken from the file\n-   `--target, env:TARGET, optional`: target environment (production, preview, development) (default: preview)\n-   `--telegram-token, env:TELEGRAM_TOKEN, required`: Telegram bot token\n-   `--token, env:VERCEL_TOKEN, optional`: Vercel token. If not specified, the token will be taken from the file\n-   `--telegram-webhook-secret, env:TELEGRAM_WEBHOOK_SECRET, optional`: Telegram bot webhook secret. If not specified, the secret will be generated randomly\n\n### Setup Telegram webhook\n\n-   `tgvercel hook \u003cdeploymentIdOrUrl\u003e \u003ctelegramBotRoute\u003e`: setup Telegram webhook\n\nArguments:\n\n-   `\u003cdeploymentIdOrUrl\u003e`: Deployment ID or URL\n-   `\u003ctelegramBotRoute\u003e`: Telegram bot route\n-   `--token, env:VERCEL_TOKEN, optional`: Vercel token. If not specified, the token will be taken from the file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharnyk%2Ftgvercel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharnyk%2Ftgvercel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharnyk%2Ftgvercel/lists"}