Hashi
橋 Hashi - A Telegram two-way chatbot implemented using Cloudflare Workers
Install / Use
/learn @so1ve/HashiREADME
橋 Hashi
A Telegram two-way chatbot implemented using Cloudflare Workers
English | 简体中文
Features
- Supports two-way communication for various message types including text, images, and more
- (Optional) human verification based on Cloudflare Turnstile
Deployment
Create a Telegram Bot
- Search for
@BotFatherin Telegram and start a conversation. - Send
/newbotor click theOpenbutton, and follow the prompts to create a new bot. - After creation, remember to save the
BOT_TOKENyou receive.
Create a Chat Group
- Create a Telegram group and enable the topics feature for the group.
- Add the bot as an administrator. It's recommended to grant all permissions (message management, topic management).
- Use
@getidsbotto get the group ID (add it to the group chat), and remember theGROUP_IDyou receive.
(Optional) Get Cloudflare Turnstile Keys
Visit Cloudflare Dashboard, create a widget, and you can fill in any hostname for now. Get and remember the TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY.
Deploy to Cloudflare Workers
First, fork this repository to your GitHub account. Then click the button below to deploy:
<img src="https://deploy.workers.cloudflare.com/button" alt="Deploy to Cloudflare">
- Select your GitHub account and the forked repository, then click
Continue. - Fill in any name, then click
Create and Deploy. - After the deployment fails, click
Continueto enter the dashboard page. - Click
Settings, and add the following environment variables inVariables and Secrets:BOT_TOKEN: The bot token obtained from BotFatherGROUP_ID: The group ID obtained from the backend group- (Optional)
TURNSTILE_SITE_KEY: Cloudflare Turnstile Site Key - (Optional)
TURNSTILE_SECRET_KEY: Cloudflare Turnstile Secret Key
- Click
Save and Deploy, and wait for the deployment to complete.
After deployment is complete, go back to the Overview page, copy the domain from Domains & Routes, and return to the Turnstile dashboard to add the domain to the Hostnames list of the widget you created.
Usage
Communication
- Search for and open your bot in Telegram, then click the
Startbutton. - The bot will send a message, follow the prompts to complete human verification.
- After successful verification, you can start bidirectional communication with the bot!
Administration
In the backend group, you can use the following commands in the General topic for management:
/settings: Modify settings and prompt text.
In the topic where you're conversing with a user, you can use the following commands:
/block: Block bidirectional chat with the current user./unblock: Unblock the current user.
Human Verification
You can enable or disable the human verification feature in the settings. If enabled, users need to complete verification before starting communication with the bot; if disabled, users can communicate directly with the bot. Enabling human verification requires providing TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY during deployment.
Credits
This project was inspired by ctt. Thanks to iawooo for the excellent work!
