mirror of
https://github.com/healthchecks/healthchecks.git
synced 2026-04-25 06:55:53 +03:00
[GH-ISSUE #689] Telegram integration without webhook but with chat-id #497
Labels
No labels
bug
bug
bug
feature
good-first-issue
new integration
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/healthchecks#497
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stevenengland on GitHub (Aug 4, 2022).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/689
Hi, I like the selfhosted version of healthchecks. But I don't want a public availability to use the Telegram integration (webhook). It would be so much easier if one could only provide the bot token and an chat id as the target. Uptime Kuma for example does it exactly this way. Healthchecks would then need to call the API endpoint https://core.telegram.org/bots/api#sendmessage with the given data.
@cuu508 commented on GitHub (Aug 4, 2022):
The problem is that sending and receiving the "/start" command requires the Healthchecks instance to be at least partially open to the world, right?
One workaround you can use right now is to create the Telegram integration manually from admin. Put the bot token in the
TELEGRAM_TOKENenv var, and create the integration in Django admin. For the integration to work, you will need to set the Project, Kind and Value fields:The value of the
idfield is the chat id. The bot must already be invited to that chat.@stevenengland commented on GitHub (Aug 4, 2022):
Mh, I might be wrong but I think you don't need the start command at all if the bot is invited to the group and is able to read messages from there that ar not commands (seperate bot setting). The only "problem" then is to find out the chat id by yourself because otherwise you would need to call getUpdates from within healthchecks to automate this too.
Thank you for your workaround. I'll look into this.
@stevenengland commented on GitHub (Aug 4, 2022):
Workaround works :) Can you name a dedicated command to realize the same? So I can add it to my IaC Runbook (Ansible).
@cuu508 commented on GitHub (Aug 4, 2022):
There currently isn't a command or API call to automate this.
@cuu508 commented on GitHub (Aug 4, 2022):
PS. Except for running a SQL INSERT query, which would be even more of a workaround :-)
@stevenengland commented on GitHub (Aug 4, 2022):
Ok. I thought of something like this which I use to pre-install an admin user to my derived image:
@DerDanilo commented on GitHub (Aug 6, 2022):
Can we add this as alternative to the Telegram integration setup? When clicking to add the integration that it gives the option to provide the chat-id instead?
@setop commented on GitHub (Aug 26, 2022):
The thing is, to avoid spam, a bot can't talk to a user directly. The user has to initiate the conversation. That is talk first, send the first message. Hense the usage of "/start" in the onboarding of tg integration of HC.
@stevenengland commented on GitHub (Aug 28, 2022):
The /start thing is okay so far. But the Webhook thing should not be the only option to setup Telegram. As mentioned, providing a chat id is all it takes to set up HC <-> Telegram. If someone (like me) would like to set this up without the webhook it is still no problem. Create a group, invite the bot, text around including the /start command, use the bot API to find out the chat id and provide it to HC. That is a bit more manual but does not require webhooks.
@cuu508 commented on GitHub (Oct 7, 2022):
I'm not planning to work on this myself, but would accept a PR.
@kiler129 commented on GitHub (Jan 31, 2023):
There's an easy workaround for this issue - simply use ... a webhook to Telegram API.
1. Create your bot by messaging @BotFather
/newbotand follow the prompts1234567:foobarbaz2. Get
chat_idhttps://api.telegram.org/bot<BOT_TOKEN>/getUpdates, replacing<BOT_TOKEN>(including<and>) with your token (e.g.1234567:foobarbaz)chat_idis the one inchat=>id(444 in this example)3. Configure HealthChecks
POSThttps://api.telegram.org/bot<BOT_TOKEN>/sendMessage(replace<BOT_TOKEN>with your token from step 1)Example configuration:

@jjscaria commented on GitHub (Jun 23, 2023):
In addition to the above, you can also add
message_thread_idfor targeting a topic in a group. You can find topic id in the topic info. It will be the digits after the last/.Ex:
t.me/c/12345678/13"message_thread_id": 13All available parameters are here: https://core.telegram.org/bots/api#sendmessage