Add logging to debug button parameter issue
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
6c5012929f
commit
668f796a05
@ -515,18 +515,26 @@ class WhatsAppService:
|
||||
# where {{1}} is replaced by a dynamic parameter
|
||||
if button_type == "URL" and button_url:
|
||||
button_param_key = tpl.get("button_param_key", "")
|
||||
logger.info(f"[WhatsApp] Button check - type={button_type}, url={button_url}, param_key={button_param_key}, has_placeholder={'{{{{1}}}}' in button_url}")
|
||||
|
||||
# Check if URL has {{1}} placeholder for dynamic parameter
|
||||
if "{{1}}" in button_url and button_param_key:
|
||||
# Dynamic URL button - need to send the parameter value
|
||||
param_value = str(params.get(button_param_key, "")).strip()
|
||||
logger.info(f"[WhatsApp] Dynamic button - param_key={button_param_key}, param_value={param_value}")
|
||||
|
||||
if param_value:
|
||||
logger.info(f"[WhatsApp] Sending button component with value: {param_value}")
|
||||
components.append({
|
||||
"type": "button",
|
||||
"sub_type": "url",
|
||||
"index": "0",
|
||||
"parameters": [{"type": "text", "text": param_value}],
|
||||
})
|
||||
# else: Static URL button - no parameters needed in the API call
|
||||
else:
|
||||
logger.warning(f"[WhatsApp] Button parameter '{button_param_key}' is empty! params keys: {list(params.keys())}")
|
||||
else:
|
||||
logger.warning(f"[WhatsApp] Button conditions not met - url has placeholder: {'{{{{1}}}}' in button_url}, has param_key: {bool(button_param_key)}")
|
||||
|
||||
# Handle url_button component if defined in template (legacy dynamic buttons)
|
||||
url_btn = tpl.get("url_button", {})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user