2017 © Pedro PelĂĄez
 

library wit-php

Wit.ai php sdk

image

tgallice/wit-php

Wit.ai php sdk

  • Sunday, January 8, 2017
  • by tgallice
  • Repository
  • 5 Watchers
  • 55 Stars
  • 7,565 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 13 Forks
  • 8 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

Wit.ai PHP sdk

Scrutinizer Code Quality Code Coverage Build Status, (*1)

This is an unofficial php sdk for Wit.ai and it's still in progress..., (*2)

Wit.ai: Easily create text or voice based bots that humans can chat with on their preferred messaging platform.

 Install:

Via composer:, (*3)

$ composer require tgallice/wit-php

Usage:

Using the low level Client:, (*4)


require_once __DIR__.'/vendor/autoload.php'; 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);

You can used the Message api class to extract meaning of a sentence:, (*5)


require_once __DIR__.'/vendor/autoload.php'; 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');

Conversation

The Conversation class provides an easy way to use the converse api and execute automatically the chaining steps :, (*6)

First, you need to create an ActionMapping class to customize the actions behavior., (*7)


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(); } .... }

And using it in the Conversation class., (*8)


require_once __DIR__.'/vendor/autoload.php'; 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');

Conversation::converse() return the last available Context., (*9)

Some examples are describe in the [tgallice/php-wit-example][2] repository., (*10)

The Versions

08/01 2017

dev-master

9999999-dev

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot

10/08 2016

dev-immutable_value_object

dev-immutable_value_object

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot

10/08 2016

0.3.1

0.3.1.0

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot

01/08 2016

0.3.0

0.3.0.0

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot

15/06 2016

0.2.0

0.2.0.0

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot

22/04 2016

0.1.0

0.1.0.0

Wit.ai php sdk

  Sources   Download

MIT

The Requires

 

The Development Requires

bot chatbot wit.ai wit.ai sdk chat bot