Skip to content

Commit

Permalink
Merge pull request #292 from plivo/SMS-7359
Browse files Browse the repository at this point in the history
SMS-7359 : Adding paramater_name
  • Loading branch information
Vishnukumarpg authored Feb 25, 2025
2 parents 5c92f70 + f43a403 commit b9292a8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [4.58.6](https://github.com/plivo/plivo-python/tree/v4.58.6) (2025-02-25)
**Enhancement - Supporting parameter_name in WhatsApp Template .**
- Supporting parameter_name in WhatsApp Template .

## [4.58.5](https://github.com/plivo/plivo-python/tree/v4.58.5) (2025-02-18)
**Feature - Throw GeoPermissionError on synchronous geopermissions error**

Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,52 @@ response= client.messages.create(
print(response)
```

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

Example:
```python
import plivo
from plivo.utils.template import Template

client = plivo.RestClient('<auth_id>','<auth_token>')

template=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="the_from_number",
dst="the_to_number",
type_="whatsapp",
template=template
)
print(response)
```

### More examples
Refer to the [Plivo API Reference](https://www.plivo.com/docs/messaging/api/overview/) for more examples. Also refer to the [guide to setting up dev environment](https://www.plivo.com/docs/messaging/quickstart/python-flask/) on [Plivo Developers Portal](https://www.plivo.com/docs/) to setup a Flask server & use it to test out your integration in under 5 minutes. to get started with Plivo.

Expand Down
6 changes: 4 additions & 2 deletions plivo/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ class Parameter:
payload=[optional(of_type_exact(str))],
currency=[optional(of_type_exact(dict))],
date_time=[optional(of_type_exact(dict))],
location=[optional(validate_dict_items(Location))]
location=[optional(validate_dict_items(Location))],
parameter_name=[optional(of_type_exact(str))],
)
def __init__(self, type, text=None, media=None, payload=None, currency=None, date_time=None, location=None):
def __init__(self, type, text=None, media=None, payload=None, currency=None, date_time=None, location=None, parameter_name=None):
self.type = type
self.text = text
self.media = media
self.payload = payload
self.currency = Currency(**currency) if currency else None
self.date_time = DateTime(**date_time) if date_time else None
self.location = location
self.parameter_name = parameter_name

class Component:
@validate_args(
Expand Down
2 changes: 1 addition & 1 deletion plivo/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '4.58.5'
__version__ = '4.58.6'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='plivo',
version='4.58.5',
version='4.58.6',
description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML',
long_description=long_description,
url='https://github.com/plivo/plivo-python',
Expand Down

0 comments on commit b9292a8

Please sign in to comment.