All Projects → lesterchan → Telegram Bot

lesterchan / Telegram Bot

Telegram Bot using AWS API Gateway and AWS Lambda

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Telegram Bot

Rssbot
Lightweight Telegram RSS bot for notifications only. 用于消息通知的轻量级 Telegram RSS 机器人
Stars: ✭ 952 (+891.67%)
Mutual labels:  bot, telegram-bot, telegram
Nikoro
A plugin-based, all-in-one, Telegram Bot written in Node.js
Stars: ✭ 51 (-46.87%)
Mutual labels:  bot, telegram-bot, telegram
Spytrojan keylogger
[Solo para programadores] Troyano espía | Keylogger solo para Windows, se replica en el sistema y se inicia automaticamente al iniciar sesión. | Envío de registro mediante [Base de Datos], [Gmail] o [BotTelegram].
Stars: ✭ 32 (-66.67%)
Mutual labels:  bot, telegram-bot, telegram
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+753.13%)
Mutual labels:  bot, telegram-bot, telegram
Telebot
The easy way to write Telegram bots in Node.js
Stars: ✭ 1,096 (+1041.67%)
Mutual labels:  bot, telegram-bot, telegram
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-81.25%)
Mutual labels:  bot, telegram-bot, telegram
Marvin
The paranoid bot (framework)
Stars: ✭ 51 (-46.87%)
Mutual labels:  bot, telegram-bot, telegram
Tgbot Cpp
C++ library for Telegram bot API
Stars: ✭ 439 (+357.29%)
Mutual labels:  bot, telegram-bot, telegram
Pockebot
Read It Later for Telegram
Stars: ✭ 56 (-41.67%)
Mutual labels:  bot, telegram-bot, telegram
Bot Telegram
Exemplo de como criar um BOT para o melhor app de mensagens do mundo: Telegram.
Stars: ✭ 53 (-44.79%)
Mutual labels:  bot, telegram-bot, telegram
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+676.04%)
Mutual labels:  bot, telegram-bot, telegram
Tgdr
Telegram directory to discover channels, bots and groups.
Stars: ✭ 91 (-5.21%)
Mutual labels:  bot, telegram-bot, telegram
Zabbix In Telegram
Zabbix Notifications with graphs in Telegram
Stars: ✭ 710 (+639.58%)
Mutual labels:  bot, telegram-bot, telegram
Pytelbot
A playful bot in telegram
Stars: ✭ 12 (-87.5%)
Mutual labels:  bot, telegram-bot, telegram
Telegraf
Modern Telegram Bot Framework for Node.js
Stars: ✭ 5,178 (+5293.75%)
Mutual labels:  bot, telegram-bot, telegram
Moviemagnetbot
🤖 telegram bot for movies
Stars: ✭ 39 (-59.37%)
Mutual labels:  bot, telegram-bot, telegram
Groupbutler
This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!
Stars: ✭ 399 (+315.63%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot
Ruby gem for building Telegram Bot with optional Rails integration
Stars: ✭ 433 (+351.04%)
Mutual labels:  bot, telegram-bot, telegram
Telepyth
Telegram notification with IPython magics.
Stars: ✭ 54 (-43.75%)
Mutual labels:  bot, telegram-bot, telegram
Turibot
TuriBot is a simple way to communicate with Telegram APIs in PHP
Stars: ✭ 68 (-29.17%)
Mutual labels:  bot, telegram-bot, telegram

Telegram Bot

A tutorial on creating a Node.js Telegram bot using AWS Lambda with AWS API Gateway.

Telegram Bot

Build Status

Build Status

Setup

I am choosing Asia Pacific (Singapore) region for AWS Lambda and Asia Pacific (Singapore) region for AWS API Gateway.

Telegram

  1. Go to Telegram Web.
  2. Start a chat with @BotFather.
  3. Type "/start".
  4. Type "/newbot" to create a new bot. I named my bot "lesterchan_bot".
  5. Note the HTTP API access token that @BotFather will reply you after you created the bot.

Checkout Code

$ git clone https://github.com/lesterchan/telegram-bot.git  
$ cd telegram-bot  
$ npm install --production
$ cp token.sample.js token.js

Open up token.js and fill in your Telegram HTTP API access token obtained in the first step then run this command:

$ zip -r telegram-bot.zip *.js node_modules/*

AWS Lambda

  1. Go to AWS Lambda.
  2. Click "Get Started Now".
  3. Under the "Select blueprint" screen, search for "hello-world"and you will see the hello-world blueprint which says "A starter AWS Lambda function.".
  4. Click on "hello-world" (NOT "hello-world-python").
  5. You will be brought to the "Configure Function" page.
  6. Under "Name", you can choose any name for your function. I called it "telegram-bot".
  7. Under "Runtime", ensure it is "Node.js".
  8. Under "Code entry type", choose "Upload a .ZIP file" and click the "Upload" button" to browse for the file "telegram-bot.zip" which you have zipped previously.
  9. Under "Handler", we leave it as "index.handler".
  10. Under "Role", we choose "Basic Execution Role".
  11. You will be brought to a "Role Summary" page.
  12. Under "IAM Role", choose "lambda_basic_execution".
  13. Under "Role Name", choose "oneClick_lambda_basic_execution_.....".
  14. Click "Allow".
  15. You will be brought back to the "Configure Function" page.
  16. Leave "Memory (MB)" as "128MB".
  17. You might want to increase "Timeout" to "15" seconds.
  18. Under VPC, choose "No VPC".
  19. Click "Next".
  20. Click "Create function".

AWS API Gateway

  1. Go to AWS API Gateway.
  2. Click "Get Started Now".
  3. Under "API name", enter the name of your API. I will just name it "Telegram Bot".
  4. Click "Create API".
  5. You will be redirected to the "Resources" page.
  6. Click "Create Method" and on the dropdown menu on the left, choose "POST" and click on the "tick" icon.
  7. Now, you will see the "/ - POST - Setup" page on the right.
  8. Under "Integration Type", choose "Lambda Function".
  9. Under "Lambda Region", choose "ap-southeast-1".
  10. Under "Lambda Function", type "telegram" and it should auto-complete it to "telegram-bot".
  11. Click "Save" and "Ok" when the popup appears.
  12. You will be brought to the "/ - POST - Method Execution" Page.
  13. Click "Integration Request".
  14. Click "Mapping Templates" and the section should expand.
  15. Click "Add Mapping Template" and type in "application/json" and click on the "tick" icon.
  16. Under "Input Passthrough" on the right, click on the "pencil" icon.
  17. Choose "Mapping Template" on the dropdown that appears.
  18. Copy and paste {"body": $input.json('$')} to the template box.
  19. Click on the "tick" icon beside the dropdown once you are done.
  20. Click on "Deploy API" button on the top left.
  21. Under "Deployment Stage", click "New Stage".
  22. Under "Stage Name", I will type in "production".
  23. Click "Deploy".
  24. Note the "Invoke URL" at the top and your API is now live.

Set Telegram Webhook

  1. Replace <ACCESS_TOKEN> with your Telegram HTTP API access token obtained in the first step.
  2. Replace <INVOKE_URL> with your Invoke URL obtained in the previous step.
  3. Run this command:
$ curl --data "url=<INVOKE_URL>" "https://api.telegram.org/bot<ACCESS_TOKEN>/setWebhook"

You should get back a response similar to this:

$ {"ok":true,"result":true,"description":"Webhook was set"}

Testing via Telegram

  1. Message your Telegram Bot that you have created.
  2. Type in "/haze" (without the quotes).
  3. You should get back a nicely formatting response as shown in the first screenshot.

Commands

Singapore Bus Arrival Timings

Usage: /bus <busStopNo> <busNo>
Example: /bus 30111 991

Usage: /bus <busStopNo>
Example: /bus 44591

Singapore Haze Situation

Usage: /haze
Example: /haze

Singapore Weather 2 Hour Forecast

Usage: /weather
Example: /weather

IP Information

Usage: /ipinfo <ip>
Example: /ipinfo 8.8.8.8

Social Stats Count For Links

Usage: /socialstats <url>
Example: /socialstats https://lesterchan.net

See Also

Slack Bot using AWS API Gateway and AWS Lamda

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].