Firebase cloud functions as Webhooks
First, get your own Telegram Bot token.
Create file functions/src/local.ts, with content:
export const BOT = {
token: '<telegram-bot-token>',
apiPrefix: 'https://api.telegram.org/bot<telegram-bot-token>',
chatId: '<telegram-chat-id>',
};
The chatId
can be a Telegram Channel or a Group, you can find it easily through Telegram Web.
- Channel: find this in the browser address bar:
im?p=c<channel-id>_xxx
,chatId
for this channel will be-100<channel-id>
- Likewise, for Group
im?p=g<group-id>
, thechatId
will be-<group-id>
Finally, don't forget to add your bot to the Channel or Group!
- Run
firebase init
- or create .firebaserc manually
{ "projects": { "default": "<firebase-project-id>" } }
- run
(cd functions && yarn deploy)