graph api fix

This commit is contained in:
debu-2 2026-10-03 03:06:55 +05:30
parent 248acba741
commit 6810f392cc
2 changed files with 22 additions and 18 deletions

View file

@ -115,21 +115,24 @@ def _build_template_components(
customer_name: str,
report_url: str,
) -> list[dict]:
"""Build Meta template components using positional variables.
"""Build Meta template components for agent_run_completion.
agent_run_completion uses:
body {{1}} -> customer name
button {{1}} -> report URL path suffix OR full URL depending on Meta template config.
We pass the full hosted report URL for the button so the View Report link resolves correctly.
Meta template uses parameter_format=NAMED for the body (customer_name) and a
positional URL-button suffix for the View Report link.
"""
components: list[dict] = [
{
"type": "body",
"parameters": [{"type": "text", "text": customer_name.strip()}],
"parameters": [
{
"type": "text",
"parameter_name": "customer_name",
"text": customer_name.strip(),
}
],
}
]
if template.button_label and template.button_url_base:
# Meta URL button: pass path suffix relative to button_url_base (e.g. desi-clans-test/2026-10-03)
base = template.button_url_base.rstrip("/")
button_param = report_url[len(base) + 1 :] if report_url.startswith(f"{base}/") else report_url
components.append(
@ -319,6 +322,6 @@ def build_agent_message_docs(template: AgentMessageTemplate) -> dict:
"Messages are sent from the Urmi AI WhatsApp business number on your behalf.",
"Create the report group in Console → Agent → Urmiport before sending.",
"If report_id is omitted, Urmi generates a unique postfix automatically.",
"The WhatsApp button uses positional template variables: body {{1}} = customer_name, button suffix = report_group/report_id.",
"Body uses named parameter customer_name; button URL suffix is report_group/report_id.",
],
}