sa3dany / android-sms-hooks

Webhooks for SMS. Sends a POST request to a custom endpoint each time you receive an SMS message
Mozilla Public License 2.0
55 stars 16 forks source link

Telegram Bot API Support #9

Open immaro opened 2 years ago

immaro commented 2 years ago

Hi, thanks for this tool! How about adding Telegram Bot API Support?

Reference: https://core.telegram.org/bots/api#sendmessage

It's currenly impossible to forward messages to Telegram due to specific JSON payload requirements, such as text and _chatid.

immaro commented 2 years ago

On the preferences side, settings like Bot token and Chat ID could be added.

sa3dany commented 2 years ago

Hi @immaro, Thanks for the suggestion. I think the best way for the app to support different services that accept incoming webhooks is to be able to create multiple webhooks in the app, each with their own URL and if I support some popular incoming webhooks you could create a webhook for a specific service.

At the moment though I am not going to be adding big changes to the app because I am busy currently. However with little work you can still forward messages to the telegram bot API if you follow the guide in the readme about receiving webhooks in Google Sheets, you can add code that will read the data in the webhook then create a new JSON payload and send that to Telegram.

Let me know if you need help with that. I can provide an example and could also add it to the README in the future.

sa3dany commented 2 years ago

@immaro I experimented a bit with the Telegram bot API but it looks like it is not possible to initiate a conversation directly from a bot to a user. The use must open a conversation with the bot, then the bot's server must poll (or receive webhooks) from Telegram for incoming conversations. Once the bot receives a conversation ID, it can then reply to the conversation.

I can't see how sms-hooks fits in that workflow.