1. Go to this page and download the library: Download tgallice/wit-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tgallice / wit-php example snippets
use Tgallice\Wit\Client;
$client = new Client('app_token');
$response = $client->get('/message', [
'q' => 'Hello I live in London',
]);
// Get the decoded body
$intent = json_decode((string) $response->getBody(), true);
use Tgallice\Wit\Client;
use Tgallice\Wit\MessageApi;
$client = new Client('app_token');
$api = new MessageApi($client);
$meaning = $api->extractMeaning('Hello I live in London');
namespace Custom;
use Tgallice\Wit\Model\Step\Action;
use Tgallice\Wit\Model\Step\Message;
class MyActionMapping extends ActionMapping
{
/**
* @inheritdoc
*/
public function action($sessionId, Context $context, Action $step)
{
return call_user_func_array(array($this, $step->getAction()), array($sessionId, $context));
}
/**
* @inheritdoc
*/
public function say($sessionId, Context $context, Message $step)
{
echo $step->getMessage();
}
....
}
use Tgallice\Wit\Client;
use Tgallice\Wit\ConverseApi;
use Tgallice\Wit\Conversation;
use Custom\MyActionMapping;
$client = new Client('app_token');
$api = new ConverseApi($client);
$actionMapping = new MyActionMapping();
$conversation = new Conversation($api, $actionMapping);
$context = $conversation->converse('session_id', 'Hello I live in London');
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.