Response processor for wit.ai
Project description
wit-core
wit-core is a message processor for wit.ai.
Handle your intents by defining actions and responses.
Getting Started
Prerequisites
- Python 3.6+
Install wheel package.
pip install wheel
Instalation
pip install wit-core
Documentation
Domain
The domain.yaml defines how the chatbot should operate according to the definition of the intents.
In the domain you specify the intents, actions and responses.
greet:
response:
text: "Hello, there!"
temperature_set:
action: action_temperature
response:
text: "The temperature was changed to {action_return}"
order_pizza:
action: action_pizza
response:
template: template_pizza
Actions
Actions are ways for you to write your own codes. For example, manipulating entities, make an API call, or to query a database.
def custom_action(resource):
temperature = resource.get_entity("wit$temperature")
return temperature.value
The resource parameter allows accessing the properties of the wit.ai response.
Resource properties:
get_latest_message
Returns the message sent by the user.
get_intent
Returns the properties of the intent.
get_entity("entity_name")
Returns the properties of the specified entity.
get_trait("trait_name")
Returns to the properties of the specified trait.
Responses
It is possible to define two types of responses: plain text and templates.
Text
You can directly in the domain specify in the response a text response quickly.
Templates
Templates serve to give you the possibility to add some logic to the answer. Templates receive the return value of an action.
def custom_template(action_return):
# Template logic...
return "Some response"
Command Line Interface
wit-core init
Creates the directory structure.
wit-core shell
Loads the domain and allows interaction with the chatbot.
wit-core http-server
Creates a http server that can be used for custom integrations. They provide a URL where you can post messages.
wit-core websocket-server
Create a websocket server for real-time interaction with the chatbot. They provide an endpoint where you can send messages.
How to use
Creates the folder structure needed for the project.
wit-core init
Create a .env at the root of the application with your secret wit.ai key.
# Wit.ai
ACCESS_TOKEN=YOUR-SECRET-KEY
Interact with the chatbot.
wit-core shell
Contributing
- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Development
Clone the repository:
git clone https://github.com/LucasOliveiraS/wit-core
Install the dependencies:
poetry install
Run tests:
make tests
Project details
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
File details
Details for the file wit-core-0.1.4.tar.gz
.
File metadata
- Download URL: wit-core-0.1.4.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.0 Linux/5.4.0-1046-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c256d4a3997b30a35c694f3927019c41c6fc3aeb01d1a5385c0cb67a7e12d788 |
|
MD5 | 4ea7ec88fbd10f6fc1a1344776d6082e |
|
BLAKE2b-256 | 057481723c32bdaefab5c60bac7308f8a666fb9c9934512ec83ce3c007b0eeb1 |
File details
Details for the file wit_core-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: wit_core-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.0 Linux/5.4.0-1046-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edabc01dd7d0cbec6e1598011d7f74315a166f0108f5e98e23222f86d5e8dc6d |
|
MD5 | a420c9e96c004f48e05020eeba01e0b7 |
|
BLAKE2b-256 | 825445cc50e8a09d5c9a9c1866de4524927bbe1350d4b7fc4f62d88682296a6e |