Giter Site home page Giter Site logo

elixir_wit's Introduction

MIT licensed Build Status Inline docs Made with Spacemacs

Wit

Elixir client for the Wit API. Wit is the natural language engine for creating Bots.

Documentation

API documentation is available at https://hexdocs.pm/elixir_wit

Installation

The package can be installed as:

  1. Add elixir_wit to your list of dependencies in mix.exs:
def deps do
  [{:elixir_wit, "~> 1.0.0"}]
end

Usage

1. Create action module

To handle the different actions from the Wit.ai API you have to create a module that implements the default callbacks and also custom actions if you have any.

The custom actions can be created by defaction macro. It expected to have three parameters i.e. session which is the session id, the context which contains the context of the conversation and message which is the raw message sent from Wit. The name of the custom action should match the one registered in Wit.

defmodule WeatherActions do
  use Wit.Actions

  def say(session, context, message) do
    # Send the message to the user
  end

  def merge(session, context, message) do
    context # Return the updated context
  end

  def error(session, context, error) do
    # Handle error
  end

  defaction fetch_weather(session, context, message) do
    context # Return the updated context
  end
end

2. Call the run action

After you have create the action module you can call the Wit using the module which will keep on calling the wit /converse API until the API returns stop.

Wit.run_actions(access_token, session_id, WeatherActions, "What is the weather?")

You can also use interactive/4 which creates an interactive session with your model in Wit.

Low Level APIs

The client also provides the functions to call the low level message and converse API.

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.