Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Change Log

## [4.66.5](https://github.com/plivo/plivo-php/tree/v4.66.5) (2025-02-25)
**Enhancement - Supporting parameter_name in WhatsApp Template .**
- Supporting `parameter_name` in WhatsApp Template .

## [4.66.4](https://github.com/plivo/plivo-php/tree/v4.66.4) (2025-02-18)
**Enhancement**
-Handle the error response from the send sms api
Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,55 @@ print_r($response);
?>
```

### Templated WhatsApp Messages With Named Parameter
This guide shows how to send templated WhatsApp messages with named parameters.

Example:
```php
<?php
require 'vendor/autoload.php';
use Plivo\RestClient;

$client = new RestClient("<auth_id>","<auth_token>");

$template = '{
"name": "template_name",
"language": "en_US",
"components": [
{
"type": "header",
"parameters": [
{
"type": "text",
"parameter_name": "header_title",
"text": "WA-header"
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"parameter_name": "user_name",
"text": "Saurabh"
}
]
}
]
}';

$response = $client->messages->create([
"src" => "+14156667778",
"dst" => "+14156667777",
"type"=> "whatsapp",
"template"=> $template,
"url"=> "https://foo.com/wa_status/"
]);
print_r($response);
?>
```

### Free Form Messages
Non-templated or Free Form WhatsApp messages can be sent as a reply to a user-initiated conversation (Service conversation) or if there is an existing ongoing conversation created previously by sending a templated WhatsApp message.

Expand Down
2 changes: 2 additions & 0 deletions src/Plivo/Util/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Parameter {
public $currency;
public $date_time;
public $location;
public $parameter_name;

public function __construct(array $data)
{
Expand All @@ -65,6 +66,7 @@ public function __construct(array $data)
$this->currency = isset($data['currency'])? new Currency($data['currency']) : null;
$this->date_time = isset($data['date_time']) ? new DateTime($data['date_time']) : null;
$this->location = isset($data['location']) ? new Location($data['location']) : null;
$this->parameter_name = isset($data['parameter_name'])? $data['parameter_name'] : null;
validateNotNullAndDataType($this->type, 'parameter', 'type', 'string', true);
validateNotNullAndDataType($this->text, 'parameter', 'text', 'string');
validateNotNullAndDataType($this->media, 'parameter', 'media', 'string');
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Version
* @const int PHP helper library patch number
*/

const PATCH = 4;
const PATCH = 5;

/**
* @return string
Expand Down
Loading