pro-cms / whatsappcloud-php

Opensource php wrapper to WhatsApp Cloud API.
MIT License
75 stars 22 forks source link

Support for parameters on send_template #1

Open dardoguidobono opened 2 years ago

dardoguidobono commented 2 years ago

https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates

add support for setting the header parameters { "messaging_product": "whatsapp", "to": "5XXXXXXXXXXX", "type": "template", "template": { "name": "test_template", "language": { "code": "es_MX" }, "components": [{ "type": "header", "parameters": [ { "type": "text","text": "111" } ] } ] } } and body parameters like this { "messaging_product": "whatsapp", "to": "5XXXXXXXXXXX", "type": "template", "template": { "name": "prueba_confirmacion_turno", "language": { "code": "es_MX" }, "components": [{ "type": "body", "parameters": [ { "type": "text","text": "111" },{ "type": "text","text": "222" },{ "type": "text","text": "333" },{ "type": "text","text": "444" } ] } ] } }

pro-cms commented 2 years ago

Hello @dardoguidobono Thanks for the suggestion, if I understood correctly its about Interactive Message Templates, ill work on that and update asap or you can create a pull request if you already have one. It should be available soon.

dardoguidobono commented 2 years ago

currently i don't have it sorted yet, the 3rd parameter for send_template is optional send_template($template, $recipient_id, $lang = "en_US") so probably i have to add 3 new arrays of parameters for the sections header, body, and button. and add the different kind of parameter classes ( Text, Date, Currency, Etc). send_template($template, $recipient_id, $lang = "en_US", $parameters_header = [], $parameters_body = [], $parameters_button = []) or create a new function with the extended parameters.

D.

aalbarca commented 2 years ago

I have just created a similar package with support for template components. Should we unify both projects and collaborate together?

m7mdcc commented 2 years ago

I have just created a similar package with support for template components. Should we unify both projects and collaborate together?

Yes Please !

bihariraj commented 2 years ago

how can we use variables in template ?

neckish commented 2 years ago

Hi! any news about request?

rupadana commented 1 year ago

You can use it now like this

Sample

$tsap->sendTemplate('template_name', '6283xxxxxx', 'en_US', [ "Hello World", ]);

equivalent to

$tsap->sendTemplate('template_name', '6283xxxxxx', 'en_US', [ [ "type" => "text", "text" => "Hello World" ], ]);