🔹 Introduction: Interactive Conversations That Convert
Don’t just send messages—send smart responses. WhatsApp interactive features like lists and buttons increase engagement and reduce drop-offs.
📘 Why Use WhatsApp Templates?
WhatsApp requires all outbound messages to use pre-approved templates. These templates include placeholders and must be submitted for approval before use.
💬 Benefits of Interactive Messages:
Lists and quick-reply buttons improve user experience by allowing users to choose options instead of typing responses. This is particularly useful for booking, support menus, or product catalogs.
🔁 Pro Tip on Reliability:
Add retry logic when sending messages via APIs. WhatsApp may rate-limit traffic or fail requests occasionally.
Handling WhatsApp Message Types
if message_type == "text": incoming_text = payload.get("content") elif message_type == "interactive": list_reply = payload.get("interactive", {}).get("listReply", {}) incoming_text = list_reply.get("title") elif message_type == "button": button_data = payload.get("button", {}) incoming_text = button_data.get("text") else: incoming_text = None
Sending Interactive Lists (Example: Product Selection)
def send_product_list(to_number: str): client = NotificationMessagesClient.from_connection_string(CONN_STR) products = [ ActionGroupItem(id="product_a", title="Product A", description="Description A"), ActionGroupItem(id="product_b", title="Product B", description="Description B"), ] action_group = ActionGroup(title="Available Products", items_property=products) action_group_content = ActionGroupContent(title="Select a Product", groups=[action_group]) list_action_bindings = WhatsAppListActionBindings(content=action_group_content) interactive_message = InteractiveMessage( header=TextMessageContent(text="Choose a Product"), body=TextMessageContent(text="Select from the list below:"), footer=TextMessageContent(text="Your Company"), action=list_action_bindings ) interactive_notification = InteractiveNotificationContent( channel_registration_id=CHANNEL_ID, to=[to_number], interactive_message=interactive_message ) client.send(interactive_notification)
Sending WhatsApp Template Messages
def send_template_message( recipient_phone_number: str, template_name: str, template_language: str, template_parameters: dict = None, add_buttons: bool = False, image_urls: list = None ): client = NotificationMessagesClient.from_connection_string(CONN_STR) template_values = [] if image_urls and len(image_urls) > 0: header_value = MessageTemplateImage(name="header", url=image_urls[^0]) template_values.append(header_value) if template_parameters: text_values = [ MessageTemplateText(name=str(idx + 1), text=clean_template_text(str(value))) for idx, (key, value) in enumerate(template_parameters.items()) ] template_values.extend(text_values) # Add buttons if needed if add_buttons: quick_action_param1 = MessageTemplateQuickAction(name="quick_reply1", payload="Action 1") quick_action_param2 = MessageTemplateQuickAction(name="quick_reply2", payload="Action 2") template_values.extend([quick_action_param1, quick_action_param2]) # Bindings body_bindings = [ WhatsAppMessageTemplateBindingsComponent(ref_value=str(idx + 1)) for idx in range(len(template_parameters) if template_parameters else 0) ] header_binding = WhatsAppMessageTemplateBindingsComponent(ref_value="header") if image_urls else None button_binding1 = WhatsAppMessageTemplateBindingsButton(sub_type=WhatsAppMessageButtonSubType.QUICK_REPLY, ref_value="quick_reply1") if add_buttons else None button_binding2 = WhatsAppMessageTemplateBindingsButton(sub_type=WhatsAppMessageButtonSubType.QUICK_REPLY, ref_value="quick_reply2") if add_buttons else None message_template = MessageTemplate( name=template_name, language=template_language ) message_template.template_values = template_values message_template.bindings = WhatsAppMessageTemplateBindings( header=[header_binding] if header_binding else None, body=body_bindings, buttons=[button_binding1, button_binding2] if add_buttons else None ) template_notification = TemplateNotificationContent( channel_registration_id=CHANNEL_ID, to=[recipient_phone_number], template=message_template ) client.send(template_notification)
Tips:
- Use WhatsApp listReply IDs for tracking user choices.
- Sanitize and truncate template parameters for compliance.
- Use images and quick-reply buttons to improve engagement.
🔹 Engagement Tip:
Test different template messages for CTAs like “Book Now” vs. “Schedule Appointment” to increase user action by 30%.
Section Summary
Here, you explored how to craft engaging conversations on WhatsApp using templates, lists, and buttons. You also saw how to handle different incoming message types programmatically. By integrating these interactive features, your chatbot can offer a richer, more guided user experience—ideal for improving conversion rates and reducing friction.