HTTP API Reference

Create a new intent

Currently the API only accepts expressions without entities.

Arguments

The request body can contain
- a JSON object with the fields below
- an array of JSON objects with the fields below

name required type doc
name required string Name of the new intent
doc optional string Short sentence describing this intent
metadata optional string String containing additional info for this intent
expressions optional array Possible expressions for this intent. Currently the API only accepts expressions without entities.
meta optional json Need a “states” field that contains an array of states associated with this intent (see notes below)

Notes

To add states to your intent, use the field meta. If any, the intent won’t be activated for stateless queries. See more.
For example:

{
  "name" : "email_answer",
  "doc" : "to detect the preference between email or sms",
  "metadata" : "answer_id=1122",
  "meta" : {
    "states" : ["email_or_text","another_state"]
  },
  "expressions" : [{"body" : "email"}, {"body" : "text"},{"body" : "sms"}]
}

Definition

  GET https://api.wit.ai/intents

Example request

  $ curl -XPOST 'https://api.wit.ai/intents?v=20141022' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"flight_request",
       "doc":"detect flight request",
       "expressions":[{
          "body" : "fly from incheon to sfo"
        }, {
          "body" : "I want to fly from london to sfo"
        },{
          "body" : "need a flight from paris to tokyo"
        }]}'

Example response

{
  "intents" : [ {
    "id" : "8bbd17dc-b383-4f19-802e-dfc86d57cb23",
    "name" : "flight_request"
  }]
}

Example request with an array of intents

  $ curl -XPOST 'https://api.wit.ai/intents?v=20141022' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '[{"name":"car_request",
       "doc":"detect car request",
       "expressions":[{
          "body" : "book a rental car in London"
        }, {
          "body" : "need to get a car in paris"
        }]},
        {"name":"uber_request",
       "doc":"detect uber request",
       "expressions":[{
          "body" : "find a uber in London"
        }]}]'

Example response with an array of intents

{
  "intents" : [ {
    "id" : "fbe55d5b-a98b-4b56-a39b-00040679511a",
    "name" : "car_request"
  }, {
    "id" : "a0b8621b-01a7-4ba1-b7d6-cc5032bf8e5b",
    "name" : "uber_request"
  } ]
}

Create a new entity

Creates a new entity with the given attributes.

Arguments

The request body must contain a JSON object with the given fields:

name required type doc
id required string ID or name of the requested entity
doc optional string Short sentence describing this entity
values optional array Possible values for this entity

Definition

  POST https://api.wit.ai/entities

Example request

  $ curl -XPOST 'https://api.wit.ai/entities?v=20141022' \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"doc":"A city that I like",
       "id":"favorite_city",
             "values":[{"value":"Paris",
                                    "expressions":["Paris", "City of Light", "Capital of France"]}]}'

Example response

  {
    "lang" : "en",
    "closed" : false,
    "exotic" : false,
    "values" : [ {
      "expressions" : [ "Paris" ],
      "value" : "Paris"
    } ],
    "builtin" : false,
    "doc" : "A city that I like",
    "name" : "favorite_city",
    "id" : "5418abc7-cc68-4073-ae9e-3a5c3c81d965"
  }