1. Go to this page and download the library: Download linqelio/linqelio-laravel 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/ */
use Linqelio\Laravel\Facades\Linqelio;
use Linqelio\Laravel\Data\Enums\MessageType;
Linqelio::messages()->sendText($contactId, 'Your order has shipped');
use Linqelio\Laravel\Events\MessageReceived;
class NotifyOperator
{
public function handle(MessageReceived $event): void
{
$message = $event->message(); // fetched only if you ask
Operator::notify($message?->text());
}
}
public function handle(MessageStatusChanged $event): void
{
if ($event->hasFailed()) {
// $event->reason says why: an unaddressable recipient, an unsupported
// type. It will not be retried.
Log::warning('send failed', ['id' => $event->messageId, 'why' => $event->reason]);
}
}
$registered = Linqelio::webhooks()->register('https://your-app.test/linqelio/webhook',
['message.inbound']);
$registered->id(); // the subscription
$registered->secret; // the signing key — SHOWN ONCE, see below
Linqelio::webhooks()->disable($id); // stop delivering, keep the subscription
Linqelio::webhooks()->enable($id);
Linqelio::webhooks()->delete($id); // unsubscribe for good
// The platform mints one and hands it back — the only time it is ever returned.
$registered = Linqelio::webhooks()->register($url, ['message.inbound']);
$registered->secret; // put this in webhooks.secret before it goes out of scope
// Or sign with a key your deployment already holds. It goes to the platform's
// secret store; nothing reads it back.
Linqelio::webhooks()->register($url, ['message.inbound'],
secret: config('linqelio.webhooks.secret'));
// Or point at one already in that store, if you administer it yourself.
Linqelio::webhooks()->register($url, ['message.inbound'],
secretRef: 'secret://webhooks/your-app');
$result = Linqelio::contacts()->erase($contactId);
$result->toArray(); // ['contacts' => 1, 'identities' => 3, ...] — record this
use Linqelio\Laravel\Models\LinqelioMessage;
LinqelioMessage::query()
->forContact($contactId)
->inbound()
->where('text', 'like', "%invoice%")
->latest('occurred_at')
->get();
use Linqelio\Laravel\Concerns\HasLinqelioContact;
class Customer extends Model
{
use HasLinqelioContact; // needs a nullable linqelio_contact_id column
}
$customer->linkLinqelioContact(ChannelKind::WaWeb, phone: '+380501082555');
$customer->queueMessage('Thanks for your order');
$customer->linqelioMessages()->latest('occurred_at')->get();
use Linqelio\Laravel\Exceptions\{PolicyException, ChannelException, LinqelioException};
try {
Linqelio::messages()->sendText($contactId, $text);
} catch (PolicyException $e) {
// rate limited or over quota
retryIn($e->retryAfter() ?? 60);
} catch (ChannelException $e) {
// not connected, or the contact is not reachable there
report($e->errorCode()->value);
} catch (LinqelioException $e) {
report($e);
}