A Cloudflare Worker-based Telegram bot that provides information about free support services and resources for people in need. A subproject of the Here to Help.
/start
- Welcome message and list of available commands/help
- Usage instructions/suicide
- Information about suicide prevention and self-harm/violence
- Information about domestic violence and physical abuse/illness
- Information about chronic illnesses/addiction
- Information about addiction and substance abuse/general
- General support resources/website
- Get the website URL
- Clone the repository
git clone https://github.com/iranian-github/here-to-help-tg-bot
cd here-to-help-tg-bot-worker
- Install dependencies
npm install
- Copy the sample environment variables file and fill in your values
cp .dev.vars.sample .dev.vars
- Delete the webhook (if set) to test locally
curl -X POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/deleteWebhook
- Start the development server
npm run dev
Once your development server is running, you can test the bot using cURL commands. Here are some examples:
curl -X POST http://localhost:8787 \
-H "Content-Type: application/json" \
-d '{
"message": {
"text": "Hello",
"chat": {"id": YOUR_CHAT_ID},
"from": {"id": YOUR_CHAT_ID}
}
}'
# Test /start command
curl -X POST http://localhost:8787 \
-H "Content-Type: application/json" \
-d '{
"message": {
"text": "/start",
"chat": {"id": YOUR_CHAT_ID},
"from": {"id": YOUR_CHAT_ID},
"entities": [{"type": "bot_command", "offset": 0, "length": 6}]
}
}'
# Test /help command
curl -X POST http://localhost:8787 \
-H "Content-Type: application/json" \
-d '{
"message": {
"text": "/help",
"chat": {"id": YOUR_CHAT_ID},
"from": {"id": YOUR_CHAT_ID},
"entities": [{"type": "bot_command", "offset": 0, "length": 5}]
}
}'
Note: Replace YOUR_CHAT_ID
with your actual Telegram chat ID.
To deploy to Cloudflare Workers:
npm run deploy
After deployment, set up your webhook URL:
curl -X POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook \
-H "Content-Type: application/json" \
-d '{"url": "https://your-worker-url.workers.dev"}'
This software is licensed under the MIT License. for more information, please see the LICENSE file.