Giter Club home page Giter Club logo

wit-core's Introduction

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

wit-core's People

Contributors

lucasoliveiras avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.