This package automates the process of bot creation
Project description
ChatBotMaker
This project aims to automate plateform messaging where the plateform support message forwarding.
Description
This module is based around a bot class in which you inject the necessary code / objects:
- Messenger (An object that sends message or event back)
- Dispatcher (An object that contains all the logic rule)
- Database (An object that allows database interaction)
Components
Messenger
You can create your own messenger class that should inherit the
chatbotmaker.Messenger class.
It must implement a send(user_id: str, message:str)
method and can implement other optional methods.
Dispatcher
The dispatcher recieves your config as a dictionnary in the following format:
{ 'actions': { 'handle\_name': { 'pref-func': lambda user: user.send\_message('Hi there'), 'func': lambda user, user\_input: user.change\_state('home'), 'post-func': lambda user: user.send\_message('You are redirected'), }, 'home': { 'pref-func': lambda user: user.send\_message('Welcome back!'), 'func': 'lambda user, user\_input: user.change\_state(user\_input)', }, 'input': { 'func': 'lambda user, user\_input: ( user.store\_argument('input', user\_input), user.change\_state('home'), )', }, } }
The user is the orm User class to whom we add some method (redirect failing attribute calls):
- send_message(message: str)
- change_state(state: str)
- get_argument(name: str)
- store_argument(name: str, value: str)
- self.messenger, self.dispatcher, self.database (the one onjected in the bot)
Database
The given database database follows the following architecture:
- users:
- id = Column(Integer, primary_key=True)
- fb_id = Column(String)
- state = Column(String)
- arguments = relationship('Argument', back_populates='user', lazy='dynamic')
- arguments:
- id = Column(Integer, primary_key=True)
- name = Column(String)
- value = Column(String)
- user_id = Column(Integer, ForeignKey('users.id'))
- user = relationship('User', uselist=False, back_populates='arguments')
The database expects a config (sqlachemy.config) object to initialize the database. You can postpone the database creation using create_database=False), add your own ORM classes using the database.base attribute and construct the database using database.create_database().
Usage
Default components
To avoid re-inventing the wheel, some "common" components have already been coded. They are in chatbotmaker.default.
- FacebookMessenger(authentication_token)
- facebook_route(request, facebook_check_token, bot)
- this flask routing should be called directly from the routing point
Dev
We have the dev file containing:
- DevMessenger() # prints everythin in console
Installation
Using PIP since its a pip module repository:
42sh$ : pip install chatbotmaker
Contributing
Do no hesitate to make a pull request or launch a discussion. I am looking foreward to expand the default capabilites.
Authors and acknowledgment
Author:
Dominique MICHEL dominique.michel@epita.fr
Status
The project has reached its first final phase. Now there will be:
- need to think about the design and facilitate user-database integration
- Good work done here, maybe allow any orm engiine ine the future
- need of tests (why not make a CI pipeline)
- tests must tests more the content of the calls
- github ci pipeline is so confusing coming from gitlab :o
Once the backend is functional and robust, i aim to make a frontend plateform to allow non-programming people to create bots too.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chatbotmaker-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af3623f3d0a8aff87be0a7b111b64402490dc95079229f7ec1371bcfc8d8e67 |
|
MD5 | b0bebcc6a8d13ff97143394dfc8d7f4b |
|
BLAKE2b-256 | 569d123a8bb98b87680d7b571e6ebecadfeec6742925aa8007b391c342ed0e4c |