Skip to main content

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

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. 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

wit-core-0.1.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

wit_core-0.1.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file wit-core-0.1.2.tar.gz.

File metadata

  • Download URL: wit-core-0.1.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.0 Linux/5.4.0-1043-azure

File hashes

Hashes for wit-core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5753de70b094c86e3a4ab85963976edecc66abd001338fbeaf87cb3f4e202ad4
MD5 17c6d4e21cd44dd1f7dd4af493a3d7c1
BLAKE2b-256 0c0ff3dd3e2418c2c2e1c09158b4ddb175956eb367ec11f943f5711ee40b7034

See more details on using hashes here.

File details

Details for the file wit_core-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: wit_core-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.0 Linux/5.4.0-1043-azure

File hashes

Hashes for wit_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f6d6d4438ab41b0bda9bc78149577c5468038ee083287c96e2b212dcf94ddd5
MD5 730c35f651eccb22353ea88da0f5dc70
BLAKE2b-256 0666608f4921a28a23c8512644db7c60a67b65a9a0877fd6b1cc6d61e1ebd00e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page