PHPackages                             cubesoftware/cube-connect-sdk-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. cubesoftware/cube-connect-sdk-php

ActiveLibrary[API Development](/categories/api)

cubesoftware/cube-connect-sdk-php
=================================

Official Laravel SDK for CubeConnect WhatsApp Business Platform

1.0.1(1mo ago)06MITPHPPHP ^8.1

Since May 18Pushed 1mo agoCompare

[ Source](https://github.com/CubeSoftLabs/cube-connect-sdk-php)[ Packagist](https://packagist.org/packages/cubesoftware/cube-connect-sdk-php)[ Docs](https://docs.cubeconnect.io)[ RSS](/packages/cubesoftware-cube-connect-sdk-php/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

CubeConnect for Laravel
=======================

[](#cubeconnect-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/f52647411cd4b8811a7febcb3fbd7967e49abfcc0aaab041692bd7fe514742b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63756265736f6674776172652f637562652d636f6e6e6563742d73646b2d7068702e737667)](https://packagist.org/packages/cubesoftware/cube-connect-sdk-php)[![License](https://camo.githubusercontent.com/a720a46e120add67e35fdb88a38dfba3217f5880707f86e32b1f1ff0586a45b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63756265736f6674776172652f637562652d636f6e6e6563742d73646b2d7068702e737667)](https://packagist.org/packages/cubesoftware/cube-connect-sdk-php)[![PHP Version](https://camo.githubusercontent.com/8f1a19a754fa26909f075c9a8dae27425d611abe4f32337051c0019eba978be1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f63756265736f6674776172652f637562652d636f6e6e6563742d73646b2d7068702e737667)](https://packagist.org/packages/cubesoftware/cube-connect-sdk-php)

Official Laravel SDK for the [CubeConnect](https://cubeconnect.io) WhatsApp Business Platform.

Installation
------------

[](#installation)

```
composer require cubesoftware/cube-connect-sdk-php
```

The package auto-discovers its service provider and facade. No manual registration required.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=cubeconnect-config
```

### Environment Variables

[](#environment-variables)

```
CUBECONNECT_API_KEY=your_api_key_here
CUBECONNECT_WHATSAPP_ACCOUNT_ID=your_account_id_here

```

VariableDefaultDescription`CUBECONNECT_API_KEY`—Your API key — **Settings → API** in the dashboard`CUBECONNECT_WHATSAPP_ACCOUNT_ID`—Your WhatsApp account ID — **Dashboard → WhatsApp Numbers → API ID:**`CUBECONNECT_URL``https://cubeconnect.io`API base URL`CUBECONNECT_TIMEOUT``30`Request timeout in seconds`CUBECONNECT_WEBHOOK_SECRET``null`Webhook signing secret for signature verificationMultiple WhatsApp Numbers
-------------------------

[](#multiple-whatsapp-numbers)

If your account has more than one connected number, set a default in your `.env` and override it per call using the `$whatsappAccountId` parameter:

```
// Send from the default number (CUBECONNECT_WHATSAPP_ACCOUNT_ID)
CubeConnect::sendTemplate('+966501234567', 'order_confirmation', 'ar', ['ORD-1234']);

// Send from a different number
CubeConnect::sendTemplate(
    '+966501234567',
    'offer_reminder',
    'ar',
    ['50%'],
    null,                  // $scheduledAt
    null,                  // $timezone
    '01JX_MARKETING',      // $whatsappAccountId — override
);

// List templates for a specific number
$templates = CubeConnect::getTemplates('APPROVED', '01JX_MARKETING');

// Create a campaign from a specific number
CubeConnect::createCampaign([
    'message_type'        => 'template',
    'template_name'       => 'offer_reminder',
    'template_language'   => 'ar',
    'recipients'          => [...],
    'whatsapp_account_id' => '01JX_MARKETING',  // override
]);
```

Find each number's ID in **Dashboard → WhatsApp Numbers → API ID:**.

Usage
-----

[](#usage)

### sendText()

[](#sendtext)

ParameterTypeRequiredDescription`$phone`stringYesRecipient phone number with country code`$body`stringYesMessage text (max 4096 characters)`$scheduledAt`string|nullNoISO 8601 datetime for scheduled delivery`$timezone`string|nullNoIANA timezone. Required when `$scheduledAt` is set`$whatsappAccountId`string|nullNoOverride the default WhatsApp account (useful with multiple numbers)```
use CubeConnect\Facades\CubeConnect;

$response = CubeConnect::sendText('+966501234567', 'مرحباً بك في متجرنا!');

$response->status;       // "queued"
->messageLogId; // "01JXXX..."
```

Scheduled delivery:

```
$response = CubeConnect::sendText(
    '+966501234567',
    'تذكير: موعدك غداً الساعة 10 صباحاً.',
    '2026-05-01T09:00:00', // $scheduledAt (ISO 8601)
    'Asia/Riyadh',         // $timezone (IANA)
);

$response->status;      // "scheduled"
$response->scheduledAt; // "2026-05-01T06:00:00Z" (UTC)
```

### sendTemplate()

[](#sendtemplate)

ParameterTypeRequiredDescription`$phone`stringYesRecipient phone number with country code`$name`stringYesTemplate name (e.g., `order_confirmation`)`$languageCode`stringYesLanguage code matching the approved template (e.g., `ar`, `en_US`)`$params`arrayNoParameters mapping to `{{1}}`, `{{2}}`, etc.`$scheduledAt`string|nullNoISO 8601 datetime for scheduled delivery`$timezone`string|nullNoIANA timezone. Required when `$scheduledAt` is set`$whatsappAccountId`string|nullNoOverride the default WhatsApp account (useful with multiple numbers)```
use CubeConnect\Facades\CubeConnect;

$response = CubeConnect::sendTemplate(
    '+966501234567',          // $phone
    'order_confirmation',     // $name
    'ar',                     // $languageCode
    ['ORD-1234', '500 SAR'],  // $params → {{1}}, {{2}}
);

$response->status;               // "queued"
$response->messageLogId;         // 4521
$response->conversationCategory; // "UTILITY"
$response->queued();             // true
```

Without parameters:

```
$response = CubeConnect::sendTemplate('+966501234567', 'welcome_message', 'ar');
```

Scheduled delivery:

```
$response = CubeConnect::sendTemplate(
    '+966501234567',
    'appointment_reminder',
    'ar',                      // $languageCode
    ['Dr. Ahmed', '10:00 AM'], // $params
    '2026-05-01T09:00:00',     // $scheduledAt (ISO 8601)
    'Asia/Riyadh',             // $timezone (IANA)
);

$response->status;      // "scheduled"
$response->scheduledAt; // "2026-05-01T06:00:00Z" (UTC)
```

### createCampaign()

[](#createcampaign)

Send a pre-approved template to a large list in a single API call.

ParameterTypeRequiredDescription`message_type`stringYesMust be `template``template_name`stringYesTemplate name (same as `$name` in `sendTemplate()`)`template_language`stringYesLanguage code (same as `$languageCode` in `sendTemplate()`)`recipients`arrayYesList of recipients. Max 50,000`recipients[].phone`stringYesRecipient phone number`recipients[].name`stringNoRecipient display name`recipients[].variables`arrayNoPer-recipient variables (e.g., `['1' => 'Ahmed', '2' => 'ORD-1234']`)`campaign_name`stringNoHuman-readable campaign name`scheduled_at`stringNoISO 8601 datetime for scheduled delivery`timezone`stringNoIANA timezone. Required when `scheduled_at` is set`whatsapp_account_id`stringNoOverride the default WhatsApp account```
$campaign = CubeConnect::createCampaign([
    'message_type'      => 'template',
    'template_name'     => 'order_confirmation',
    'template_language' => 'ar',
    'recipients'        => [
        ['phone' => '+966501234567', 'name' => 'Ahmed', 'variables' => ['1' => 'Ahmed', '2' => 'ORD-1234']],
        ['phone' => '+966509876543', 'name' => 'Sara',  'variables' => ['1' => 'Sara',  '2' => 'ORD-5678']],
    ],
    'campaign_name' => 'Order Notifications',
]);

$campaign->campaignId; // "01JX..."
$campaign->status;     // "pending"
$campaign->totalCount; // 2
```

Scheduled delivery:

```
$campaign = CubeConnect::createCampaign([
    'message_type'      => 'template',
    'template_name'     => 'offer_reminder',
    'template_language' => 'ar',
    'recipients'        => [...],
    'campaign_name'     => 'Flash Sale',
    'scheduled_at'      => '2026-05-01T09:00:00', // ISO 8601
    'timezone'          => 'Asia/Riyadh',            // IANA timezone
]);

$campaign->status;        // "pending"
$campaign->isScheduled(); // true
```

#### Get Campaign Status

[](#get-campaign-status)

```
$campaign = CubeConnect::getCampaign($campaignId);

$campaign->status;        // "processing", "completed", "cancelled", "failed"
$campaign->totalCount;    // 500
$campaign->sentCount;     // 320
$campaign->failedCount;   // 12
$campaign->isCompleted(); // true
```

#### Cancel a Scheduled Campaign

[](#cancel-a-scheduled-campaign)

```
$ok = CubeConnect::cancelCampaign($campaignId); // true on success
```

### List Templates

[](#list-templates)

```
$templates = CubeConnect::getTemplates('APPROVED');

foreach ($templates as $t) {
    $t->name;         // "order_confirmation"
    $t->paramsCount;  // 3
    $t->body;         // "Hello {{1}}, your order {{2}} has been shipped."
    $t->header;       // null
    $t->isApproved(); // true
}
```

### Get Message Status

[](#get-message-status)

Retrieve the current delivery status of a previously sent message using the `messageLogId` returned by `sendTemplate()`.

```
$msg = CubeConnect::getMessageStatus(4521);

$msg->messageLogId;  // 4521
$msg->status;        // "delivered"
$msg->toPhone;       // "966501234567"
$msg->messageType;   // "template"
$msg->metaMessageId; // "wamid.HBgN..."
$msg->sentAt;        // "2026-05-01T07:05:00Z"
$msg->scheduledAt;   // null
$msg->costAmount;    // 0.05
$msg->costCurrency;  // "SAR"
$msg->errorMessage;  // null (set if status is "failed")

$msg->isSent();      // true if status is "sent"
$msg->isDelivered(); // true if status is "delivered"
$msg->isRead();      // true if status is "read"
$msg->isFailed();    // true if status is "failed"
$msg->isScheduled(); // true if status is "scheduled"
```

### Health Check

[](#health-check)

```
$health = CubeConnect::health();
// ['status' => 'healthy', 'checks' => [...], 'timestamp' => '...']
```

Webhooks
--------

[](#webhooks)

Receive real-time notifications from CubeConnect for messages, campaigns, templates, chatbot flows, and quality events.

### Setup

[](#setup)

```
CUBECONNECT_WEBHOOK_SECRET=your_webhook_secret_here

```

### Signature Verification Middleware

[](#signature-verification-middleware)

```
// routes/api.php
use CubeConnect\Webhooks\WebhookHandler;

Route::post('/cubeconnect/webhook', [WebhookController::class, 'handle'])
    ->middleware(WebhookHandler::class);
```

### Handling Webhook Events

[](#handling-webhook-events)

```
use CubeConnect\DTOs\WebhookEvent;

class WebhookController extends Controller
{
    public function handle(Request $request)
    {
        $event = WebhookEvent::fromRequest($request);

        match (true) {
            $event->isMessageReceived()       => $this->handleMessage($event),
            $event->isMessageStatusUpdated()  => $this->handleStatus($event),
            $event->isCampaignCompleted()     => $this->handleCampaign($event),
            $event->isTemplateStatusChanged() => $this->handleTemplate($event),
            $event->isFlowSessionCompleted()  => $this->handleFlow($event),
            $event->isQualityEvent()          => $this->handleQuality($event),
            default => null,
        };

        return response('OK', 200);
    }
}
```

### Supported Events

[](#supported-events)

EventMethodDescription`message.status_updated``isMessageStatusUpdated()`Message status change (sent, delivered, read, failed)`message.received``isMessageReceived()`Incoming message from a customer`campaign.created``isCampaignCreated()`New campaign created`campaign.started``isCampaignStarted()`Campaign execution started`campaign.completed``isCampaignCompleted()`Campaign finished`template.submitted``isTemplateSubmitted()`Template submitted to Meta`template.status_changed``isTemplateStatusChanged()`Template approved, rejected, or paused`flow.session_started``isFlowSessionStarted()`Chatbot flow session started`flow.session_completed``isFlowSessionCompleted()`Chatbot flow session completed`flow.session_cancelled``isFlowSessionCancelled()`Session cancelled by customer`account.quality_event``isQualityEvent()`Quality event (block or report)`webhook.test``isTest()`Connection test pingDependency Injection
--------------------

[](#dependency-injection)

```
use CubeConnect\Contracts\Messaging;

class OrderController extends Controller
{
    public function shipped(Order $order, Messaging $messaging)
    {
        $messaging->sendTemplate(
            $order->customer_phone,
            'order_shipped',
            'ar',
            [$order->id, $order->tracking_number],
        );
    }
}
```

Response Objects
----------------

[](#response-objects)

### MessageResponse

[](#messageresponse)

Returned by `sendText()` and `sendTemplate()`:

PropertyTypeDescription`status``string``queued` for immediate delivery, `scheduled` for future delivery`messageLogId``string`Unique tracking ID`conversationCategory``string``MARKETING`, `UTILITY`, or `AUTHENTICATION``cost``float`Message cost`scheduledAt``string|null`UTC datetime if scheduled, otherwise `null````
$response->queued();    // true if status is "queued"
$response->scheduled(); // true if status is "scheduled"
$response->toArray();   // Array representation
```

### CampaignResponse

[](#campaignresponse)

Returned by `createCampaign()` and `getCampaign()`:

PropertyTypeDescription`campaignId``string`Unique campaign ULID`name``string|null`Campaign name`status``string``pending`, `processing`, `completed`, `cancelled`, `failed``totalCount``int`Total recipients`sentCount``int`Successfully sent`failedCount``int`Failed deliveries`scheduledAt``string|null`Scheduled UTC datetime`createdAt``string`Creation timestamp```
$campaign->isScheduled(); // true if pending with a scheduledAt
$campaign->isCompleted(); // true if status is "completed"
$campaign->isCancelled(); // true if status is "cancelled"
$campaign->toArray();     // Array representation
```

### MessageStatusResponse

[](#messagestatusresponse)

Returned by `getMessageStatus()`:

PropertyTypeDescription`messageLogId``string`Unique message log ID`status``string``queued`, `scheduled`, `sent`, `delivered`, `read`, or `failed``toPhone``string`Recipient phone number`messageType``string``template` or `text``metaMessageId``string|null`WhatsApp message ID (set after delivery)`sentAt``string|null`UTC datetime when sent to WhatsApp`scheduledAt``string|null`UTC datetime of scheduled delivery`costAmount``float`Message cost`costCurrency``string`Currency code (e.g., `SAR`)`errorMessage``string|null`Error details if status is `failed``createdAt``string`UTC creation datetime```
$msg->isSent();      // true if status is "sent"
$msg->isDelivered(); // true if status is "delivered"
$msg->isRead();      // true if status is "read"
$msg->isFailed();    // true if status is "failed"
$msg->isScheduled(); // true if status is "scheduled"
$msg->toArray();     // Array representation
```

Error Reference
---------------

[](#error-reference)

HTTPError CodeCause401`AUTHENTICATION_REQUIRED`No API key provided in the request401`INVALID_API_KEY`API key is invalid or has been revoked403`FORBIDDEN`API key does not have permission for this action403`API_KEY_NO_TENANT`API key is not linked to any account404`NOT_FOUND`The requested resource does not exist404`TEMPLATE_NOT_FOUND`Template name not found in your account422`VALIDATION_ERROR`Request failed input validation — check `error.details` for field-level errors422`INVALID_PHONE_NUMBER`Phone number is not in a valid international format422`NO_ACTIVE_ACCOUNT`No connected WhatsApp number found for the given `whatsapp_account_id`422`MISSING_ACCESS_TOKEN`The selected WhatsApp number has no Meta access token configured422`TEMPLATE_LANGUAGE_MISMATCH`Language code does not match any approved version of this template422`TEMPLATE_PARAMS_MISMATCH`Fewer parameters provided than the template requires429`RATE_LIMIT_EXCEEDED`Too many API requests — apply exponential backoff and retry429`PLAN_LIMIT_REACHED`Monthly message quota reached — upgrade your plan429`SUBSCRIPTION_EXPIRED`Subscription has expired500`MESSAGE_SEND_FAILED`WhatsApp API rejected or failed to deliver the message500`INTERNAL_ERROR`Unexpected server error — contact support if this persists503`SERVICE_DEGRADED`One or more platform services are temporarily unavailableError Handling
--------------

[](#error-handling)

```
use CubeConnect\Facades\CubeConnect;
use CubeConnect\Exceptions\AuthenticationException;
use CubeConnect\Exceptions\ValidationException;
use CubeConnect\Exceptions\RateLimitException;
use CubeConnect\Exceptions\NotFoundException;
use CubeConnect\Exceptions\CubeConnectException;

try {
    CubeConnect::sendTemplate('+966501234567', 'order_confirmation', 'ar', ['ORD-1234']);
} catch (AuthenticationException $e) {
    // 401/403 — Invalid API key or permissions
    $e->errorCode;  // "INVALID_API_KEY", "FORBIDDEN", ...
    $e->statusCode; // 401 or 403
} catch (ValidationException $e) {
    // 422 — Invalid request data
    $e->errorCode; // "VALIDATION_ERROR", "INVALID_PHONE_NUMBER", ...
    $e->errors;    // ['phone' => ['The phone field is required.']]
} catch (NotFoundException $e) {
    // 404 — Resource not found
    $e->errorCode; // "NOT_FOUND", "TEMPLATE_NOT_FOUND"
} catch (RateLimitException $e) {
    // 429 — Rate or plan limit exceeded
    $e->errorCode; // "RATE_LIMIT_EXCEEDED", "PLAN_LIMIT_REACHED", ...
} catch (CubeConnectException $e) {
    // 5xx or network errors
    $e->errorCode;  // "INTERNAL_ERROR", "MESSAGE_SEND_FAILED", ...
    $e->statusCode;
}
```

Documentation
-------------

[](#documentation)

Full API documentation is available at [docs.cubeconnect.io](https://docs.cubeconnect.io).

License
-------

[](#license)

CubeConnect for Laravel is open-sourced software licensed under the [MIT license](LICENSE).

Copyright © 2026 [Cube Software](https://cubesoftware.io) (CubeSoftLabs). All rights reserved.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance91

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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

Every ~40 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25426470?v=4)[CubeSoftware](/maintainers/cubesoftware)[@CubeSoftware](https://github.com/CubeSoftware)

---

Top Contributors

[![fahadapps79](https://avatars.githubusercontent.com/u/121814410?v=4)](https://github.com/fahadapps79 "fahadapps79 (30 commits)")[![CubeSoftLabs](https://avatars.githubusercontent.com/u/264034789?v=4)](https://github.com/CubeSoftLabs "CubeSoftLabs (2 commits)")

---

Tags

cubeconnectcubesoftwarecube-connect-sdk-php

### Embed Badge

![Health badge](/badges/cubesoftware-cube-connect-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/cubesoftware-cube-connect-sdk-php/health.svg)](https://phpackages.com/packages/cubesoftware-cube-connect-sdk-php)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.7k1](/packages/jasara-php-amzn-selling-partner-api)

PHPackages © 2026

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