I have succeded with my first node app on Lambda using serverless. It works great when I open it from http endpoint after executing serverless deploy -v!
My target is to get my node.js telegram bot running on lambda. When I insert bot logic into export.module.hello , deploy in console, set telegram webhook, get no response after run /start command in my bot and then check same http endpoint webhook by opening api.telegram.org/botXXX/getWebhookinfo - what I get is “Wrong response from the webhook: 502 Bad Gateway”
this is my handler.js code:
'use strict';
module.exports.hello = async (context, cb) => {
const TelegramBot = require('node-telegram-bot-api');
const token = "token";
const bot = new TelegramBot(token);
const chatId = context.body.message.chat.id;
const out = bot.sendMessage(chatId, 'Hello World!');
return cb(null, out);
};
and this is serverless.yml (functions part of it)
functions:
hello:
handler: handler.hello
events:
- http: POST hello
I am comfortably running node.js code for telegram from a localhost, but seems cannot wrap this code inside lambda function… Otherwise what can be a problem causing 502 error, when I check getWebhookinfo?
Any advice will be much appreciated!