1. Go to this page and download the library: Download oliverearl/nomiai-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/ */
oliverearl / nomiai-php example snippets
$sdk = new \Nomiai\PhpSdk\NomiAI(
token: $yourNomiAiApiKey, // Find it in the Integrations tab of the Nomi.ai app!
// You can also provide a custom endpoint and HTTP Client as additional arguments.
);
$nomis = $sdk->getNomis();
$conversation = $sdk->sendMessageToNomi($nomis[0], 'Hello!');
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
// Get all Nomis:
/** @var array<int, \Nomiai\PhpSdk\Resources\Nomi> $nomis **/
$nomis = $sdk->getNomis();
// Grab a specific Nomi:
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/
$nomi = $sdk->getNomi(id: 'Your Nomi UUID here');
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/
// Send a message directly to a Nomi
$conversation = $sdk->sendMessageToNomi($nomi, 'Hello!');
// Or to their UUID!
$conversation = $sdk->sendMessage($nomi->uuid, 'World!');
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/
$avatar = $sdk->getAvatarFromNomi($nomi);
// Or via the UUID:
$avatar = $sdk->getAvatar($nomi->uuid);
/*
* Avatar is an object that might get more functionality down the line. For now,
* to get the underlying .webp image, access the avatar property.
*/
$webp = $avatar->avatar;
// You can also retrieve the underlying image by casting the object to a string.
$image = (string) $avatar;
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
// Get all Nomis:
/** @var array<int, \Nomiai\PhpSdk\Resources\Nomi> $nomis **/
$nomis = $sdk->getNomis();
$request = new RoomRequest(
name: 'Nomi HQ',
note: 'The coolest place for Nomis to hang out',
backchannelingEnabled: true,
nomiUuids: $nomis,
);
/** @var \Nomiai\PhpSdk\Resources\Room $room */
$room = $sdk->createRoom($request);
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Room $room **/
$request = [
'name' => 'The New Nomi HQ!',
];
$room = $sdk->updateRoom($room, $request);
// You can also update a room by its UUID, for example if you don't have the full object.
$room = $sdk->updateRoomById($room->uuid, $request);
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Room $room **/
$sdk->deleteRoom($room);
// You can also delete it by its UUID
$sdk->deleteRoomById($room->uuid);
/** @var \Nomiai\PhpSdk\NomiAI $sdk **/
/** @var \Nomiai\PhpSdk\Resources\Nomi $nomi **/
/** @var \Nomiai\PhpSdk\Resources\Room $room **/
$message = $sdk->requestNomiToMessageRoom($nomi, $room);
// If you only have the Nomi UUID, and/or the room UUID, you have options:
$message = $sdk->requestNomiByIdToMessageRoom($nomi->uuid, $room);
$message = $sdk->requestNomiByIdToMessageRoomById($nomi->uuid, $room->uuid);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.