airyhq / telegram-source-demo

This repository contains a demo integration of the Telegram Bot Api with using the Source API.

Home Page:https://docs.airy.co/api/source

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Airy Telegram source

This repository contains a demo integration of the Telegram Bot Api with Airy using the Source API.

Step by step usage guide

The goal is to get messages sent to one or more of your Telegram bots into Airy and optionally enable sending messages to Telegram using the Airy send message API.

1. Connect a source using the Airy Source API and note down the source token.

2. Create a Telegram bot using the Telegram botfather

3. Create a source channel and add the token as metadata.

Sample payload:

{
	"source_channel_id": "my-telegram-bot-id",
	"name": "My Telegram bot",
	"metadata":{
		"token": "bot token"
	}
}

4. Create an .env file and set the SOURCe_TOKEN to the one you obtained in step 1.

5. Start the development integration by running:

yarn run dev

The output will look like so:

yarn run v1.22.5
$ node build/app.js
Started local tunnel at https://lazy-eel-4.loca.lt
Example app listening at http://localhost:3000

On startup the app will fetch the registered source channels and set the webhooks to point to this app's local tunnel.

6. (Optional) Handle messages sent from Airy

Note down the local tunnel url above and update the action endpoint of your source to $tunnel_endpoint/action.

Now you can send messages to Telegram by calling the Airy send message endpoint. Example:

curl --request POST \
  --url http://airy.core/messages.send \
  --header 'Content-Type: application/json' \
  --data '{
	"conversation_id": "999532fe-7e01-53ba-bac3-17f1291f3340",
	"message": {
		"chat_id": 750379379,
		"text": "Hello Telegram, from Airy!"
	}
}'

About

This repository contains a demo integration of the Telegram Bot Api with using the Source API.

https://docs.airy.co/api/source


Languages

Language:TypeScript 94.6%Language:Handlebars 3.5%Language:CSS 1.3%Language:Shell 0.6%