RFP: Renterd Telegram Alert Bot


Project Name: Renterd/Hostd Telegram Alert Bot

Name of the organization or individual submitting the proposal: Mert Köklü

Describe your project.

Developing a Telegram bot to forward urgent Renterd and Hostd alerts to the Telegram app of end-user. Utilizing the provided endpoints from the Renterd and Hostd API, the bot will be set up to register a new webhook for alert modules, and subsequently monitor and forward any triggered alerts to the Telegram user. The core of the project will be encapsulated within a Docker container that can be easily deployed by end-users in their own environment, ensuring a seamless setup and execution with just a single command.

Why Docker, and not a Telegram bot that operates in centralized server for best user experience? I have considered this option, but there is security concerns from end-users and limitations. A centralized setup could expose all received alerts to a single point, which user may not be comfortable with. More importantly, alerts sent through webhooks to a central server, there’s a lack of unique information in the webhook endpoint response in Renterd/Hostd API to identify which Renterd/Hostd instance the alert originated from, making it impossible to alert the user.

How does the projected outcome serve the Foundation’s mission of user-owned data?

By real-time alerting users, this project enhances the user’s ability to respond to urgent alerts in a timely manner, and thus protecting their data.

Grant Specifics

Amount of money requested and justification with a reasonable breakdown of expenses:

2 months of work for $5000 that covers my time.

What are the goals of this small grant?

  • Developing a Telegram bot for alerting users of urgent Renterd alerts.

  • Developing a Telegram bot for alerting users of urgent Hostd alerts.

  • Ensuring ease of setup and use through Docker encapsulation.

  • Providing how-to documentation for end-users.

Potential risks that will affect the outcome of the project:

  • Unexpected changes or limitations in the Renterd/Hostd API. This can be mitigated by updating the bot to handle the changes.

Other than that, there is no risk of the project since it only forwards the alerts to the user, and does not modify any data.

Development Information

Will all of your project’s code be open-source?

Yes, the code will be open-source and available on Github with detailed documentation.

Leave a link where code will be accessible for review.

Do you agree to submit monthly progress reports?

Yes, I agree to submit monthly progress reports.

Contact info

Email: kklumert@gmail.com

Any other preferred contact methods:

  • Discord: MertK#2634

  • Telegram: mertkklu

have your considered also adding support for hostd?

1 Like

Yes, I thought about it in detail, and even wanted it to be in a way that users could use the hosted version if they prefer, instead of deploying it themselves.

Initial scheme was this,

  1. Deploy Telegram Bot: a telegram bot would be deployed by me with DB integration (like Firestore).
  2. Register Webhook: a code snippet would be shared with renterd user that can be found in Github doc of this project. The snippet would be used to register webhook for their renterd.
  3. Get user ID: user then make interact with bot (like register button) to give us their unique ID (this may be wallet address that will be used in renterd). Then I would save this ID in relation with that user’s Telegram chat ID in my DB.
  4. Alert Trigger: when an alert is triggered in any user’s renterd instance, the event would come to bot (thanks to webhook) and the bot would check if the user is registered in our DB based on alert message. So the problem arises here.

There is no information that stores unique ID or wallet ID in alert messages. There can be, but as far as I know (speaking of API) there isn’t always. Alers can be like in below:

    "id": "h:d6c6d018c1fb11b78213ebfe0c3f6e59ceb525ca62de6ab29c142314b5343ce5",
    "severity": "error",
    "message": "failed to refill account: couldn't fund account: unable to fetch revision with contract: LatestRevision: failed to fetch pricetable, err: PriceTable: couldn't process payment: ReadResponse: stream was gracefully closed (29.109478968s)\n",
    "data": {
      "accountID": "ed25519:9a70a6e3023863a5a23cddb064336b845744f764609d40dd7d4d50bf3870c278",
      "contractID": "fcid:194e2d0216fd24c1e2e457965c60075c644f32fb3fa74e0a1310ef006fd8bc0d",
      "hostKey": "ed25519:573096e26690c796b023eb8385b7fe476a8cc7ae645294ce736f442d26f3d782",
      "origin": "autopilot.autopilot"
    "timestamp": "2023-08-30T14:48:05.239891201Z"
    "id": "h:ff24699354782e8cf58d7074f3fa63c030ac0d81d674e141542006de99ecfa36",
    "severity": "info",
    "message": "wallet is low on funds",
    "data": {
      "address": "addr:a9adb468928455e381f8468fff2e5d0dc95e0755aef27daa9d845ed40565bf696f2637c7b19e",
      "balance": "141738724911491675264573908846",
      "origin": "autopilot.autopilot"
    "timestamp": "2023-08-30T14:45:19.922778399Z"

So the first alarm stores accountID, but the second alarm doesn’t store it. Or second alarm stores address, but first one doesn’t.

If it is guarantee that any of the alarm stores consistent unique ID information, then the above scheme would work. So that, I would fetch Telegram chat ID from my DB based on unique ID and sent message to the user.

But, because of above problem, I don’t any option to host it. I will speak with renterd team if it is possible or not, to see a solution.

Sorry, hostd and not hosted. I think it would be nice to get hosted alerts in telegram as well as maybe a renterd alerts.

1 Like

Oh, of course that would be nice. Let’s see if any Sia grant team members, or community demand alerts from also hostd. Then I will change the proposal to include also hostd alerts. Thanks

To include hostd alerts would make perfect sense as it would basically be almost the same code.

We have a grant already that focuses on a hostd monitoring service (Grant Proposal: hostd monitoring service - #8 by maju), but some diversity wouldn’t hurt.

1 Like

Yes, it would be awesome so that I was going to edit my proposal to also include hostd but unfortunately there is no webhooks implemented yet in hostd API.

Alerts in renterd triggers events in my bot thanks to webhook so I need to wait hostd developers to add webhooks like in renterd.

You might want to ask for it in new features in github. The devs have been very open to adding features that make sense. There are a lot of features that got added to rendered and hosted due to devs asking for it.

1 Like

Thanks! Sent a feature request to the Github repo.

Thanks for your proposal! The committee has a submission cutoff date of the Wednesday before their next meeting to consider a project for review. This proposal was received after our submission cutoff for their meeting on October 17th, so the committee will review this grant during their meeting on October 31st.

1 Like

Thanks @steve, patiently waiting for it.

hostd developers are implementing the webhooks (can be tracked here Github issue)! So, I am updating my proposal to also include hostd alerts.

Hey @steve, is there any update? Thank you

Hey @mert, the committee has reviewed and we will be posting responses tomorrow, Thursday November 2nd.

1 Like

Hello @mert

Congratulations, the committee has approved this proposal!

We’ll reach out via email to set up grant program onboarding. Onboarding typically takes a week or two, so free to adjust your internal timelines as appropriate.

Kino on behalf of the Sia Foundation and Grants Committee

1 Like

It is done! I have completed all milestones.

The Telegram bot is deployed and running all good. For usage, please look into this repository:

Here is the new changes/fixes to the project

  • Testing Hostd alerts will no longer report error (even though it is installed correctly). Bug reported by mittim in Discord

  • Improved formatting of message sending to Telegram and added new cases.

Question 1: I have setup the bot before. Do i need to do anything?
Nope, you don’t need to do anything. Happy new years :tada: