1. Go to this page and download the library: Download motuo/call-watson-api 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/ */
motuo / call-watson-api example snippets
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use motuo\CallWatsonAPI\CallAssistant;
class TestContoller extends Controller
{
public function index(Request $request,CallAssistant $CWA){
//provide user input message and context
$response = $CWA->postMessage('input message',session('context')?session('context'):[]);
//this method returns json.If necessary,please json decode.
$responseArray = json_decode($response,true);
//this step put a context to session for next conversation
$request->session()->put('context',$responseArray['context']);
return view('welcome');
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use motuo\CallWatsonAPI\CallDiscovery;
class TestContoller extends Controller
{
public function index(Request $request,CallDiscovery $CWD){
//Query your collection
$query = ['query'=>[
'version' => '2018-08-01',
'deduplicate' => 'false',
'highlight' => 'true',
'passages' => 'true',
'passages.count' => '5' ,
'natural_language_query' => 'natural_language_query'
]];
$CWD->queryCollection($query);
//Management training Querys
$CWD->listTrainingData();
$CWD->getQueryIdByNLQ('natural_language_query');
$CWD->addQueryToTrainingData('document_id','natural_language_query',100);
$CWD->deleteTrainingDataQuery('query_id');
//Management Examples
$CWD->listExamplesTrainingData('query_id');
$CWD->getExampleId('query_id','document_id');
$CWD->addExampleToTrainingData('query_id','document_id',100);
$CWD->deleteExampleForTrainingDataQuery('query_id','document_id');
return view('welcome');
}
}
bash
php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.