Code Monkey home page Code Monkey logo

songwhip-telegram's Introduction

A stateless 'function' endpoint that responds to HTTP events sent by Telegram Clients that are chatting to SongwhipBot directly or have SongwhipBot added to a group.

Tech overview

  • Uses Telegram WebHooks API so that the bot can be hosted in a serverless/Lambda environment, woken-up by inbound requests as opposed to polling for changes.
  • There's a risk this could be an expensive service as it listens to every message send in a group for a music link. We'll monitor it.
  • We opt-out of replying via the original inbound http response (via webhookReply: false) so that we can resolve the request straight away and send a string of follow-up messages after. This makes things simpler when sending more than one message response.
  • We're using Now V2.
  • The now.json defines production env vars, when we deploy to staging with yarn deploy:staging we override select env vars so that the @SongwhipDevBot token is used instead of @SongwhipBot and the staging endpoint songwhip-telegram.wilsonpage.now.sh is used.
  • Some bot configuration (eg. the command list or enabling 'inline' command) must be done from the Telegram app via the @BotFather bot.
  • We're using now secret from the CLi to store the Telegram bot token, which is used in now.json via the magic @songwhip-telegram-bot-token placeholder.

Establishing the webhook endpoint with Telegram

  1. Set the SONGWHIP_TELEGRAM_URL to the URL of the deployment
  2. Deploy
  3. Visit /set-webhook on the deployment to setup the connection between Telegram and the deployment endpoint.

songwhip-telegram's People

Contributors

wilsonpage avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.