* [WhatsApp template messages](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates) now supported - `template` hook is required to set whatsapp template message
Note that `template` hook is required for template message types
It should return template list of components e.g.
python
dotted.path.to.template.hook.py
from pywce import hook, HookArg, EngineConstants, TemplateDynamicBody
hook
def whatsapp_template_hook(arg: HookArg):
TODO: handle business logic
add your list of dict entries matching your template
template_components = []
arg.template_body = TemplateDynamicBody(render_template_payload={EngineConstants.WHATSAPP_TEMPLATE_KEY: template_components})
return arg
yaml
"WHATSAPP-TEMPLATE-MESSAGE":
type: template
template: "dotted.path.to.template.hook.whatsapp_template_hook"
message:
name: "<your-template-name>"
language: "your-template-lang" default to en_US
routes:
"re:.*": "NEXT-ROUTE"
* Added support for dynamic message processing
Note that `template` hook is required for dynamic message types.
Dynamic template can render any supported pywce message type.
> [!NOTE]
> Hook should return a dict that matches any supported message, message attribute structure
python
dotted.path.to.template.hook.py
from pywce import hook, HookArg, TemplateTypeConstants, TemplateDynamicBody
hook
def dynamic_message(arg: HookArg):
TODO: handle business logic
an example dynamic CTA button message
cta_btn_message = dict(
title="Developer Profile",
body="Check out my updated github profile",
url="https://github.com/DonnC",
button="GitHub"
)
arg.template_body = TemplateDynamicBody(
typ=TemplateTypeConstants.CTA,
render_template_payload=cta_btn_message
)
return arg
yaml
"DYNAMIC-MESSAGE":
type: dynamic
template: "dotted.path.to.template.hook.dynamic_message"
message: "{{ body }}"
routes:
"re:.*": "NEXT-ROUTE"