wit-core is a message processor for wit.ai.
Handle your intents by defining actions and responses.
- Python 3.6+
Install wheel package.
pip install wheel
pip install wit-core
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 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.
Returns the message sent by the user.
Returns the properties of the intent.
Returns the properties of the specified entity.
Returns to the properties of the specified trait.
It is possible to define two types of responses: plain text and templates.
You can directly in the domain specify in the response a text response quickly.
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"
Creates the directory structure.
Loads the domain and allows interaction with the chatbot.
Creates a http server that can be used for custom integrations. They provide a URL where you can post messages.
Create a websocket server for real-time interaction with the chatbot. They provide an endpoint where you can send messages.
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
- 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
Clone the repository:
git clone https://github.com/LucasOliveiraS/wit-core
Install the dependencies:
poetry install
Run tests:
make tests