This project is a template to get you started on setting up a Cloudflare Worker that listens to onchain events via Helius webhooks and sends notifications to a Telegram chat.
-
Clone this repository:
git clone git@github.com:helius-labs/cloudfare-telegram-template.git cd cloudfare-telegram-template
-
Install project dependencies:
npm install
-
Configure environment variables: Open
wrangler.toml
and fill in the following keys:TELEGRAM_BOT_TOKEN
: Your Telegram bot token (get it from @BotFather)TELEGRAM_CHAT_ID
: Your Telegram channel's chat ID (see below)HELIUS_API_KEY
: Your Helius API key (get it from Helius)
To get your Telegram channel's chat ID:
- Create a channel and add your bot as an administrator.
- Send a message to the channel.
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
- Find the
"chat":{"id":
field in the response. This is your chat ID.
Watch this video:
-
Deploy to Cloudflare:
npm run deploy
-
Create the webhook:
curl -X POST https://your-worker-url.workers.dev/create-webhook
Replace
your-worker-url
with your actual worker URL.
You can use this /webhook
endpoint for other Helius services that require a webhook URL.
That's it! Your bot should now be operational and will send messages to your Telegram channel.
Modify src/index.ts
to change webhook creation or message formatting.
- Check environment variables in
wrangler.toml
. - Ensure bot has permission to send messages to the channel.
- Review Cloudflare Worker logs for errors.
For more help, see Cloudflare Workers docs or Helius docs.