PHPackages                             cweetagram/cweetagram-vonage-whatsapp - 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. cweetagram/cweetagram-vonage-whatsapp

ActiveLibrary[API Development](/categories/api)

cweetagram/cweetagram-vonage-whatsapp
=====================================

This package is a package to handle cweetagram business models for whatsapp business services

1.0(4mo ago)01PHP

Since Dec 26Pushed 4mo agoCompare

[ Source](https://github.com/cweetagramsolutions/cweetagram-vonage-whatsapp)[ Packagist](https://packagist.org/packages/cweetagram/cweetagram-vonage-whatsapp)[ RSS](/packages/cweetagram-cweetagram-vonage-whatsapp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Cweetagram Vonage WhatsApp
==========================

[](#cweetagram-vonage-whatsapp)

A Laravel package for creating and managing WhatsApp message templates using the Vonage WhatsApp Manager API with type-safe data structures.

Features
--------

[](#features)

- 🎯 Type-safe WhatsApp template creation using `spatie/laravel-data`
- 📝 Support for all template components (Header, Body, Footer, Buttons)
- 🖼️ Multiple header formats (Text, Image, Video, Document)
- ✅ Built-in validation
- 🔄 Easy conversion to Vonage API format
- 🛠️ Template management services (Create, Delete, Get State)
- 🧪 Fully tested

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x or 11.x

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

[](#installation)

Install the package via Composer:

```
composer require cweetagram/cweetagram-vonage-whatsapp
```

Publish the configuration file:

```
php artisan vendor:publish --provider="Cweetagram\CweetagramVonageWhatsapp\VonageServiceProvider" --tag="config"
```

Add your Vonage API endpoint to your `.env` file:

```
VONAGE_API_ENDPOINT=https://api.nexmo.com/v2/
```

Configuration
-------------

[](#configuration)

The package configuration file (`config/vonage_api.php`) includes:

```
return [
    'api_endpoint' => env('VONAGE_API_ENDPOINT', 'https://api.nexmo.com/v2/'),
];
```

Usage
-----

[](#usage)

### Setting Up WABA Account Data

[](#setting-up-waba-account-data)

Before making API calls, you need to provide your WhatsApp Business Account credentials:

```
use Cweetagram\CweetagramVonageWhatsapp\Data\WabaAccountData;

$wabaAccount = new WabaAccountData(
    waba_id: 'your-waba-id',
    appJwt: 'your-jwt-token'
);
```

### Creating Templates

[](#creating-templates)

#### Simple Text Template

[](#simple-text-template)

```
use Cweetagram\CweetagramVonageWhatsapp\Data\TemplateData;
use Cweetagram\CweetagramVonageWhatsapp\Data\HeaderComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Data\BodyComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Data\FooterComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Enums\TemplateCategories;
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\CreateTemplateService;

$components = [
    HeaderComponentData::text("Congratulations")->toArray(),
    BodyComponentData::text("Lorem ipsum messages come here there")->toArray(),
    FooterComponentData::text("This is an automated message. Please do not reply")->toArray(),
];

$template = new TemplateData(
    name: "welcome_message",
    language: "en",
    category: TemplateCategories::MARKETING->value,
    allow_category_change: true,
    components: $components
);

$service = new CreateTemplateService();
$response = $service->handle($wabaAccount, $template);

if ($response) {
    // Template created successfully
    echo "Template ID: " . $response->template_id;
}
```

#### Marketing Template with Image Header

[](#marketing-template-with-image-header)

```
$components = [
    HeaderComponentData::image("https://example.com/promo.jpg")->toArray(),
    BodyComponentData::text("🎉 Special offer! Get {{1}}% off on all products. Use code: {{2}}")->toArray(),
    FooterComponentData::text("Offer valid until {{3}}")->toArray(),
];

$template = new TemplateData(
    name: "summer_sale_2024",
    language: "en",
    category: TemplateCategories::MARKETING->value,
    allow_category_change: true,
    components: $components
);

$service = new CreateTemplateService();
$response = $service->handle($wabaAccount, $template);
```

### Getting Template State

[](#getting-template-state)

Check the approval status of a template:

```
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\GetTemplateStateService;

$service = new GetTemplateStateService();
$state = $service->handle($wabaAccount, 'template-id-here');

if ($state) {
    echo "Template status: " . $state->state;
    // Possible states: APPROVED, PENDING, REJECTED, etc.
}
```

### Deleting Templates

[](#deleting-templates)

Remove a template from your WABA:

```
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\DeleteTemplateService;

$service = new DeleteTemplateService();
$service->handle($wabaAccount, 'template-id-here');
```

Header Component Types
----------------------

[](#header-component-types)

### Text Header

[](#text-header)

```
$header = HeaderComponentData::text("Welcome to Our Store");
```

### Image Header

[](#image-header)

```
$header = HeaderComponentData::image("https://example.com/image.jpg");
```

### Video Header

[](#video-header)

```
$header = HeaderComponentData::video("https://example.com/video.mp4");
```

### Document Header

[](#document-header)

```
$header = HeaderComponentData::document("https://example.com/document.pdf");
```

Body Component
--------------

[](#body-component)

Create body text with variable placeholders:

```
$body = BodyComponentData::text("Your order #{{1}} has been shipped and will arrive by {{2}}");
```

Footer Component
----------------

[](#footer-component)

Add footer text to your template:

```
$footer = FooterComponentData::text("Thank you for shopping with us");
```

Available Services
------------------

[](#available-services)

### CreateTemplateService

[](#createtemplateservice)

Creates a new WhatsApp template in your WABA.

**Method:** `handle(WabaAccountData $wabaAccountData, TemplateData $templateData): ?CreatedTemplateResponseData`

**Returns:** `CreatedTemplateResponseData` on success, `null` on failure

### GetTemplateStateService

[](#gettemplatestateservice)

Retrieves the current state/status of a template.

**Method:** `handle(WabaAccountData $wabaAccountData, string $templateId): ?TemplateStateResponseData`

**Returns:** `TemplateStateResponseData` on success, `null` on failure

### DeleteTemplateService

[](#deletetemplateservice)

Deletes a template from your WABA.

**Method:** `handle(WabaAccountData $wabaAccountData, string $templateId): void`

**Returns:** `void` (logs errors if deletion fails)

Available Template Categories
-----------------------------

[](#available-template-categories)

The package supports all Vonage WhatsApp template categories:

```
use Cweetagram\CweetagramVonageWhatsapp\Enums\TemplateCategories;

TemplateCategories::MARKETING->value;        // Marketing messages
TemplateCategories::UTILITY->value;          // Utility messages (order updates, etc.)
TemplateCategories::AUTHENTICATION->value;   // OTP and authentication
```

Available Header Formats
------------------------

[](#available-header-formats)

```
use Cweetagram\CweetagramVonageWhatsapp\Enums\HeaderFormats;

HeaderFormats::TEXT->value;      // Plain text header
HeaderFormats::IMAGE->value;     // Image header
HeaderFormats::VIDEO->value;     // Video header
HeaderFormats::DOCUMENT->value;  // Document header
```

Template Structure
------------------

[](#template-structure)

When you call `$template->toArray()` or `$template->all()`, it returns a structure compatible with Vonage's API:

```
[
    'name' => 'template_name',
    'language' => 'en',
    'category' => 'MARKETING',
    'allow_category_change' => true,
    'components' => [
        [
            'type' => 'HEADER',
            'format' => 'TEXT',
            'text' => 'Header text'
        ],
        [
            'type' => 'BODY',
            'text' => 'Body text with {{1}} variables'
        ],
        [
            'type' => 'FOOTER',
            'text' => 'Footer text'
        ]
    ]
]
```

Error Handling
--------------

[](#error-handling)

All services include built-in error handling and logging. Failed operations are logged with detailed error messages:

```
$service = new CreateTemplateService();
$response = $service->handle($wabaAccount, $template);

if ($response === null) {
    // Check logs for detailed error information
    // Error: "Failed to create template for account {waba_id} : {error_message}"
}
```

Example: Complete Workflow
--------------------------

[](#example-complete-workflow)

```
use Cweetagram\CweetagramVonageWhatsapp\Data\WabaAccountData;
use Cweetagram\CweetagramVonageWhatsapp\Data\TemplateData;
use Cweetagram\CweetagramVonageWhatsapp\Data\HeaderComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Data\BodyComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Data\FooterComponentData;
use Cweetagram\CweetagramVonageWhatsapp\Enums\TemplateCategories;
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\CreateTemplateService;
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\GetTemplateStateService;
use Cweetagram\CweetagramVonageWhatsapp\Services\Templates\DeleteTemplateService;

// 1. Set up WABA credentials
$wabaAccount = new WabaAccountData(
    waba_id: 'your-waba-id',
    appJwt: 'your-jwt-token'
);

// 2. Create template
$components = [
    HeaderComponentData::text("Order Update")->toArray(),
    BodyComponentData::text("Your order {{1}} has been {{2}}")->toArray(),
    FooterComponentData::text("Track your order anytime")->toArray(),
];

$template = new TemplateData(
    name: "order_status_update",
    language: "en",
    category: TemplateCategories::UTILITY->value,
    allow_category_change: false,
    components: $components
);

$createService = new CreateTemplateService();
$created = $createService->handle($wabaAccount, $template);

if ($created) {
    $templateId = $created->template_id;

    // 3. Check template state
    $stateService = new GetTemplateStateService();
    $state = $stateService->handle($wabaAccount, $templateId);

    if ($state) {
        echo "Template status: " . $state->state;
    }

    // 4. Delete template if needed
    // $deleteService = new DeleteTemplateService();
    // $deleteService->handle($wabaAccount, $templateId);
}
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test:coverage
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- Built with [spatie/laravel-data](https://github.com/spatie/laravel-data)
- Powered by [Vonage WhatsApp Manager API](https://developer.vonage.com/en/messages/whatsapp)

Support
-------

[](#support)

For issues, questions, or suggestions, please open an issue on GitHub.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance75

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

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

137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb3f1902ee506faeac978ab46982c1be2d803823c77ff9ca6a8a2bf27de61155?d=identicon)[chancelito](/maintainers/chancelito)

---

Top Contributors

[![chancelito](https://avatars.githubusercontent.com/u/25268810?v=4)](https://github.com/chancelito "chancelito (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cweetagram-cweetagram-vonage-whatsapp/health.svg)

```
[![Health](https://phpackages.com/badges/cweetagram-cweetagram-vonage-whatsapp/health.svg)](https://phpackages.com/packages/cweetagram-cweetagram-vonage-whatsapp)
```

###  Alternatives

[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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