Socket
Socket
Sign inDemoInstall

telegraf-aws

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    telegraf-aws

AWS Lambda helper for Telegraf bot framework


Version published
Maintainers
1
Install size
2.59 kB
Created

Readme

Source

Telegraf-aws

Small lib to ease use of AWS Lambda with Telegraf in webhook mode

Example

Small example of serverless Telegraf bot:

import Telegraf from 'telegraf'
import telegrafAws from 'telegraf-aws'

// Create telegraf instance for handle updates
const bot = new Telegraf(process.env.BOT_TOKEN, {
  webhookReply: true
})

// Create webhook handler
const updateHandler = telegrafAws(bot, {
  timeout: 1000 // Optional parameter, after timeout, empty response will be sent to AWS and function execution will be stopped
})

// Optional - set webhook url on start
bot.telegram.setWebhook(process.env.BOT_WEBHOOK_URL)

// Register bot commands
bot.command('help', ctx => ctx.reply('Try send a sticker!'))
bot.hears('hi', ctx => {
  ctx.reply('Hey there!')
})
bot.hears(/buy/i, ctx => ctx.reply('Buy-buy!'))
bot.on('sticker', ctx => ctx.reply('👍'))

// Now use hello as your lambda function and done!
export const hello = updateHandler

FAQs

Last updated on 31 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc