I'm writing a bot using Wit.ai and I'm having trouble understanding context. More specifically how/when to set it. As I've understood it you set the context by posting to the API at any point in time you see fit, for example when executing a function defined in a wit story. At least that's the approach I'm aiming for with the code below. Sadly it generates an error though so I wonder, am I trying to set the context in an incorrect way or is there something wrong with my Guzzle post?
private function storeUserName($entities) {
$witcall = $this->wit->post($this->wit_base_url.'/converse',
[
'form_params' => [
'username' => $entities->contact[0]->value
],
'query' => [
'v' => '1',
'session_id' => 'vk-'.$this->thread_id
],
'headers' => [
'Authorization' => 'Bearer '.env('WIT_TOKEN', false)
]
]
);
return [
'msg' => 'nice',
'type' => 'msg'
];
}
My error:
ClientException in RequestException.php line 111:
Client error: `POST https://api.wit.ai/converse?v=1&session_id=vk-1` resulted in a `400 Bad Request` response:
Unable to parse context in body