PHPackages                             davidniki02/api-ai-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. davidniki02/api-ai-php

ActiveLibrary[API Development](/categories/api)

davidniki02/api-ai-php
======================

API.ai php sdk

0.2.5(9y ago)14792MITPHPPHP &gt;=5.5.0

Since Aug 20Pushed 9y ago1 watchersCompare

[ Source](https://github.com/davidniki02/api-ai-php)[ Packagist](https://packagist.org/packages/davidniki02/api-ai-php)[ RSS](/packages/davidniki02-api-ai-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Api.ai PHP sdk
==============

[](#apiai-php-sdk)

This is fork of the unofficial php sdk for [Api.ai](https://api.ai) - [iboldurev/api-ai-php](https://github.com/iboldurev/api-ai-php-example)

In this fork, we have added the ability to create, update and delete intents. Specifically, it now has a better support for POST queries as well as PUT and DELETE verbs.

```
Api.ai: Build brand-unique, natural language interactions for bots, applications and devices.

```

Install:
--------

[](#install)

Via composer:

```
$ composer require davidniki02/api-ai-php

```

Usage:
------

[](#usage)

Using the low level `Client`:

```
require_once __DIR__.'/vendor/autoload.php';

use ApiAi\Client;

try {
    $client = new Client('access_token');

    $query = $client->get('query', [
        'query' => 'Hello',
    ]);

    $response = json_decode((string) $query->getBody(), true);
} catch (\Exception $error) {
    echo $error->getMessage();
}
```

Creating a sample intent with a context:

```
private function createIntent($context, $issue, $response){
    try {
        $client = new \ApiAi\Client('');

        $query = $client->post('intents', [
            "name" => "issue name",
            "auto" => true,
            "templates" => [
                $issue
            ],
            "contexts" => [
                $context
            ],
            "userSays" => [
                [
                    "data" => [
                        ["text" => $issue]
                    ],
                    "isTemplate" => false,
                    "count" => 0
                ],
            ],
            "responses" => [
                ["speech" => $response]
            ]
        ]);

        $r = json_decode((string) $query->getBody(), true);

        if ($r['status']['code'] != "200")
            return false;

        return $r;
    } catch (\Exception $error) {
        return false;
    }
}
```

Usage:
------

[](#usage-1)

Using the low level `Query`:

```
require_once __DIR__.'/vendor/autoload.php';

use ApiAi\Client;
use ApiAi\Model\Query;
use ApiAi\Method\QueryApi;

try {
    $client = new Client('access_token');
    $queryApi = new QueryApi($client);

    $meaning = $queryApi->extractMeaning('Hello', [
        'sessionId' => '1234567890',
        'lang' => 'en',
    ]);
    $response = new Query($meaning);
} catch (\Exception $error) {
    echo $error->getMessage();
}
```

Dialog
------

[](#dialog)

The `Dialog` class provides an easy way to use the `query` api and execute automatically the chaining steps :

First, you need to create an `ActionMapping` class to customize the actions behavior.

```
namespace Custom;

class MyActionMapping extends ActionMapping
{
    /**
     * @inheritdoc
     */
    public function action($sessionId, $action, $parameters, $contexts)
    {
        return call_user_func_array(array($this, $action), array($sessionId, $parameters, $contexts));
    }

    /**
     * @inheritdoc
     */
    public function speech($sessionId, $speech, $contexts)
    {
        echo $speech;
    }

    /**
     * @inheritdoc
     */
    public function error($sessionId, $error)
    {
        echo $error;
    }
}
```

And using it in the `Dialog` class.

```
require_once __DIR__.'/vendor/autoload.php';

use ApiAi\Client;
use ApiAi\Method\QueryApi;
use ApiAi\Dialog;
use Custom\MyActionMapping;

try {
    $client = new Client('access_token');
    $queryApi = new QueryApi($client);
    $actionMapping = new MyActionMapping();
    $dialog = new Dialog($queryApi, $actionMapping);

    // Start dialog ..
    $dialog->create('1234567890', 'Привет', 'ru');

} catch (\Exception $error) {
    echo $error->getMessage();
}
```

Some examples are describe in the [davidniki02/api-ai-php-example](https://github.com/davidniki02/api-ai-php-example) repository.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3601d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16925660?v=4)[David Niki](/maintainers/davidniki02)[@davidniki02](https://github.com/davidniki02)

---

Top Contributors

[![iboldurev](https://avatars.githubusercontent.com/u/17103170?v=4)](https://github.com/iboldurev "iboldurev (19 commits)")[![aleplusplus](https://avatars.githubusercontent.com/u/6319838?v=4)](https://github.com/aleplusplus "aleplusplus (1 commits)")[![davidniki02](https://avatars.githubusercontent.com/u/16925660?v=4)](https://github.com/davidniki02 "davidniki02 (1 commits)")[![pilot](https://avatars.githubusercontent.com/u/28564?v=4)](https://github.com/pilot "pilot (1 commits)")

---

Tags

botapi.aiapi.ai sdk

### Embed Badge

![Health badge](/badges/davidniki02-api-ai-php/health.svg)

```
[![Health](https://phpackages.com/badges/davidniki02-api-ai-php/health.svg)](https://phpackages.com/packages/davidniki02-api-ai-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[iboldurev/dialogflow

Dialogflow php sdk

16340.8k1](/packages/iboldurev-dialogflow)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1942.4k4](/packages/aimeos-prisma)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

464.7k](/packages/bushlanov-dev-max-bot-api-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
