Texa DeskDevelopers

Server

PHP

composer require texa/texa-php. The Texa API for Laravel, Symfony or plain PHP.

Shell
composer require texa/texa-php

PHP 8.1+ with the curl and json extensions. The package is texa/texa-php on Packagist.

PHP
$texa = new Texa\Client(getenv('TEXA_API_KEY'));
$convo = $texa->openConversation(['channel' => 'web', 'customer_ref' => 'user-1842'],
                                 idempotencyKey: 'open-user-1842');
$out = $texa->sendMessage($convo['conversation_id'],
                          ['text' => 'Where is my transfer?', 'message_id' => 'msg-551']);
$events = $texa->runActions($convo['conversation_id'], $out, [
    'get_transfer_status' => fn (array $inputs) => ['status' => 'paid_out'],
]);

Webhooks

PHP
$event = Texa\Webhooks::parse(getenv('TEXA_WEBHOOK_SECRET'), getallheaders(),
                              file_get_contents('php://input'));

Laravel: a widget session

PHP
Route::post('/texa/session', fn () => auth()->check()
    ? $texa->widgetSession('user-' . auth()->id(), ['name' => auth()->user()->name])
    : response()->json(['error' => 'not signed in'], 401));

Errors throw Texa\TexaError, with the status, code and request id.