Giter VIP home page Giter VIP logo

bot-async's Introduction

Telegram Async Chatbot Framework

A simply-complex chatbot to cater many needs at one place. This simple being can help you feed latest information out there on internet and can act according to you will.

Architecture

This app is divided in many very loosely coupled components. Some terms related to this are:

  • Interaction/Network Layer: Layer that can exchange the data/messages with Telegram and thus user and then pass the received message to the internal processing backend.

  • Interaction Manager: Receives messages from interaction layer and determines which service does this message belong.

  • Services: Top level functionality provided by bot are called Services. These consists of modules that are no where related to each other.

    Every Service consists of two components:

    • Manager: Registers the services with the Interaction Manager and exchanges the messages sent by it and passes them to the backend framework. All the managers are inherited from base_service_manager

    • Backend Framework: Final end point of messages. It is processed here and then the relevant response is sent back to te user.

    Some predefined services include

    • Publisher service: This part of bot works as the PUB-SUB system where all the publishers are the, well, Publishers and all the users are Subscribers. Publishers publish data on the channels and all the receivers receive that data.

      New sources for publishing can be easily defined by defining a class inheriting the BasePublisher.

  • Actions: There are the basic unit User-Bot interaction. The bot will issue the actions will result in some output and actions following it.

    Actions can be considered as a dynamic directed cyclic graph.

Actions flow example

made using draw.io

Tech Stack:

The bot is designed to work asynchronously.

  • The server is built upon aiohttp.
  • Whenever a message is arrived, new job is scheduled in an aiojobs scheduler.
  • Messages are sent to the user in an aiohttp ClientSession.

To utilize the benefits of asynchronous architecture, make sure you write you code using that framework only.

The complete architecture can be represented as:

Bot Architecture

made using draw.io

Storage Manager Base Class shown in the diagram is the class that will manage the database interaction. It will provide methods for storing and retrieving data from database.

TODO

  • Add database methods for Async database interaction
  • Add Sub-modules in Interaction layer for reusing the architecture for multiple messenger services

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.