Skip to content

Instantly share code, notes, and snippets.

@ohld
Created October 15, 2019 16:44
Show Gist options
  • Select an option

  • Save ohld/b9f1e2b6dd6750c5cffa93a1956019d7 to your computer and use it in GitHub Desktop.

Select an option

Save ohld/b9f1e2b6dd6750c5cffa93a1956019d7 to your computer and use it in GitHub Desktop.
Now sh (Zeit co) simple Serverless Telegram echo bot (in Python)
import os
import logging
import telegram
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/api', methods=['POST'])
def api():
bot = telegram.Bot(token=os.getenv("TELEGRAM_TOKEN"))
update = telegram.Update.de_json(request.get_json(force=True), bot)
chat_id = update.message.chat.id
# Reply with the same message
bot.sendMessage(chat_id=chat_id, text=update.message.text)
return jsonify({"status": "ok"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment