Zoozl services for chatbots
Project description
zoozl
Server for chatbot services
Usage
For basic example a chatbot plugin is provided in zoozl.plugins package. It is a simple chatbot that allows to play bulls & cows game. It is also a plugin that is loaded in case no configuration file is provided.
Run websocket server
python -m zoozl --conf chatbot.toml
where chatbot.toml is configuration file.
Architecture
zoozl package contains modules that handle various input interfaces like websocket or http POST and a chatbot interface that must be extended by plugins. Without plugin zoozl is not able to respond to any input. Plugin can be considered as a single chat assistant to handle a specific task. Plugin can be huge and complex or simple and small. It is up to the developer to decide how to structure plugins.
Plugin
Mimimal setup
- Create new toml configuration file (e.g. myconfig.toml)
extensions = ['my_plugin_module']
- Make sure
my_plugin_moduleis importable from within python that will run zoozl server - Create file
my_plugin_module.py
from zoozl.chatbot import Interface
class MyPlugin(Interface):
aliases = ("call myplugin",)
def consume(self, context: , package: Package):
package.callback("Hello this is my plugin response")
- Start zoozl server with your configuration file and asking to bot
call mypluginit will respondHello this is my plugin response
python -m zoozl --conf myconfig.toml
Plugin interface
Plugin must implement consume method that takes two arguments context and package. context is a InterfaceRoot object that contains information about the current chatbot state and package is a Package object that contains input message and callback method to send response back to the user.
Plugin may define aliases attribute that is a tuple of strings that are used to call the plugin. If aliases is not defined, plugin will not be called. Aliases are like commands that user can call to interact with the plugin, however those commands are constructed as embeddings and then compared with input message embeddings to find the best match.
Special aliases are help, cancel and greet. Help alias is used when there is no matching aliases found in plugins, cancel alias is used to cancel current conversation and release it from current plugin handling, greet alias is called immediately before any user message is handled.
If there is only one plugin expected, then aliases most likely should contain all three special aliases, thus plugin will be as soon as connection is made and everytime user asks anything.
Configuration file
Configuration file must conform to TOML format. Example of configuration:
extensions = ["chatbot_fifa_extension", "zoozl.plugins.greeter"]
websocket_port = 80 # if not provided, server will not listen to websocket requests
author = "my_chatbot_name" # defaults to empty string
slack_port = 8080 # if not provided, server will not listen to slack requests
slack_app_token = "xoxb-12333" # Mandatory if slack_port is provided, oAuth token for slack app to send requests to slack
slack_signing_secret = "abc123" # Mandatory if slack_port is provided, secret key to verify requests from slack
email_port = 8081 # if provided, server will listen to LMTP requests there
email_address = "something@localhost" # Mandatory if email_port is provided, email address to send back email messages to
email_smtp_port = 25 # Optional port for sending out email messages to, defaults to 25
[chatbot_fifa_extension] # would be considered as specific configuration for plugin
database_path = "tests/tmp"
administrator = "admin"
Root objects like author, extensions are configuration options for chatbot system wide setup, you can pass unlimited objects in configuration, however suggested is to add a component for each plugin and separate those within components.
- TODO: Describe plugin interface and creation
- TODO: Add authentication and authorization interaction between chatbot and plugin
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zoozl-0.2.6.tar.gz.
File metadata
- Download URL: zoozl-0.2.6.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d770e9bccfc7d7f8ef182797eb4668540f9b29add2b63ec613c20262e9961b8c
|
|
| MD5 |
9768a1cd3361e5ab866beae81f7dd7ed
|
|
| BLAKE2b-256 |
9ade68101ec33fd3155a79a40ea190dcf46e7f56c1cc097b94c2a31b7cc5349a
|
File details
Details for the file zoozl-0.2.6-py3-none-any.whl.
File metadata
- Download URL: zoozl-0.2.6-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbfda50f5ba612ce252b1addc008239240e6ba1df398c145bb8c4fd44a9fda38
|
|
| MD5 |
d1982d01930f49d16f9731bc3cb8185e
|
|
| BLAKE2b-256 |
f5639a9b68e91b7ed4c75530dc136c4f4de40302e355924ce29aac6afda1d7b5
|