n8n-tg-trigger
v1.0.0
Published
Telegram chat listener that triggers n8n webhooks
Downloads
15
Maintainers
Readme
n8n-tg-trigger
Telegram chat listener that triggers n8n webhooks using tg-lisa.
Installation
npm install n8n-tg-triggerUsage
CLI
npx n8n-tg-trigger --config config.jsonProgrammatic
import { N8nTgTrigger } from 'n8n-tg-trigger';
const trigger = new N8nTgTrigger({
api_id: 123456,
api_hash: 'your_api_hash',
sessionFilePath: './telegram-session.txt', // optional, defaults to './telegram-session.txt'
chatIds: ['111111', '222222'],
webhookUrl: 'https://your-n8n-instance.com/webhook/telegram'
});
await trigger.start();
// Stop listening
await trigger.stop();Configuration
Create a config.json file:
{
"api_id": 123456,
"api_hash": "your_telegram_api_hash",
"sessionFilePath": "./telegram-session.txt",
"chatIds": ["111111", "222222"],
"webhookUrl": "https://your-n8n-instance.com/webhook/telegram"
}Parameters
api_id(required): Telegram API ID from https://my.telegram.orgapi_hash(required): Telegram API hash from https://my.telegram.orgsessionFilePath(optional): Path to session file. Default:./telegram-session.txtchatIds(required): Array of chat IDs (as strings) to monitorwebhookUrl(required): n8n webhook URL
Webhook Payload
Messages are sent to the webhook with the following structure:
{
"message": {
"chatId": "111111",
"text": "Message text"
}
}Development
npm install
npm run build
npm testLicense
MIT
