Struct rustcastai::Client
[−]
[src]
pub struct Client<'a> { pub client: Client, // some fields omitted }
Fields
client: Client
Methods
impl<'a> Client<'a>
[src]
fn new(token: &'a str) -> Result<Self, RecastError>
Create a new client
The token argument is your bot's request access token. You can find this token in your bot's settings on Recast.AI
Example
let client = Client::new("YOUR_REQUEST_ACCESS_TOKEN");
fn set_language(&mut self, language: &'a str)
Set the language used to perform text_request, file_request and text_converse
The language as to be in the form of an isocode, like "en" for english For now, Recast.AI supports english and french
Example
client.set_language("en");
fn text_request(&self, text: &str) -> Result<Request, RecastError>
Call /request endpoint to analyze a text
This method will make an HTTP request on the /request endpoint of the Recast.AI API and will give you back the intent and metadata detected in your input.
Example
client.text_request("Hello, world.");
fn file_request(&self, file_name: &str) -> Result<Request, RecastError>
Call /request endpoint to analyze an audio file
This method will make an HTTP request on the /request endpoint of the Recast.AI API and will give you back the intent and metadata detected in the content of your audio file.
Example
client.file_request("test.wav");
fn text_converse(
&self,
text: &str,
conversation_token: Option<&str>
) -> Result<Converse, RecastError>
&self,
text: &str,
conversation_token: Option<&str>
) -> Result<Converse, RecastError>
Call the /converse endpoint to interact with a bot
This method will make an HTTP request on the /converse endpoint of the Recast.AI API and will give you back the action and metadata detected, along with the replies of your bot
Example
client.text_converse("Hello, what can you do?");
fn reset_memory(
&self,
conversation_token: &str
) -> Result<Response, RecastError>
&self,
conversation_token: &str
) -> Result<Response, RecastError>
Reset the memory of your bot for a specific conversation.
Example
client.text_converse("I want to change my destination") .and_then(|res| client.reset_memory(&res.conversation_token));
fn reset_conversation(
&self,
conversation_token: &str
) -> Result<Response, RecastError>
&self,
conversation_token: &str
) -> Result<Response, RecastError>
Reset the entire conversation: both memory and flow.
Example
client.text_converse("Can we start all over again?") .and_then(|res| client.reset_conversation(&res.conversation_token));