Crates.io | witty |
lib.rs | witty |
version | 1.0.0 |
source | src |
created_at | 2017-02-18 09:46:04.330043 |
updated_at | 2017-11-15 08:45:38.376732 |
description | wit.ai client library |
homepage | https://github.com/Stankec/witty |
repository | https://github.com/Stankec/witty |
max_upload_size | |
id | 8568 |
size | 13,403 |
Unofficial wit.ai client library for Rust.
This is an unofficial client implementation! It comes with no guarantees and Wit.ai can't be held responsible for any bugs that may occure from using this library in your project.
This is a port of Wit.ai's official Ruby client to Rust
Wit.ai decided to close down their chat bot / conversation API on
2018-01-01. This decision lead to the deprecation of the run_actions
and
converse
methods.
In consequence, this library now only handles communication with Wit.ai servers.
Reference the change log for detailed explanations as to what has been done to facilitate the transition.
This project is available on Crates.io, and
can be installed with cargo
.
[dependencies]
witty = "1.0.0"
To create a client you will need to get a token from Wit.ai.
extern crate witty;
use witty::Value; # Serde JSON value struct
fn main() {
let token = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
let client = witty::client(token);
let result = client.message("What's the weather like?");
match result {
Ok(response) => println!("The server returns: {:?}", response),
Err(error) => println!("Something went wrong... {:?}", error)
};
}
The Client
exposes a single method:
Used to query the API for the meaning of an input message.
message(
message: &str
) -> Result<Value, super::http::HttpError>
message
- The input message which wit.ai will process.The returned value is the context with which the API responded.
All error structs contain a message
and a code
field. The message
field is
human-readable and describes the reason why this error occured alongside with
any additional information gathered from the environment. The code
field
indicates where the error spawned and the class of issue it represents.
The following is a list of errors with their possible codes and explanations:
ExeccutionError
102
- The API responded with an error
type response.105
- The API responded with an unknown type.106
- There was a problem connecting to the API.HttpError
100
- Unable to connect to server101
- Server responded with messageNote: The HttpError
struct also has an additional status
field which
contains the response's HTTP status code. This code will also be displayed in
the message alongside with the canonical explanation.
This project is licensed under the MIT license. It's in no way affiliated with Wit.ai.