WhatsApp Agent – WhatsApp Functions
Learn how to create, manage, and use WhatsApp Functions for your WhatsApp Agent to send templated messages, automate workflows, and integrate business logic.
Overview
WhatsApp Functions enable your WhatsApp Agent to perform automated actions such as sending approved WhatsApp templates, triggering notifications, OTPs, order updates, or executing custom business workflows.
They act as reusable actions that your agent can invoke during conversations or predefined flows.
What Are WhatsApp Functions?
WhatsApp Functions allow your agent to:
- Send approved WhatsApp template messages
- Automate order updates, OTPs, alerts, and notifications
- Execute custom business logic
- Integrate with external systems using structured parameters
They are commonly used when messages must be sent outside the 24-hour session window or when strict template usage is required.
Accessing WhatsApp Functions
- Open your WhatsApp Agent from the dashboard.
- In the agent sidebar, click Functions.
- You will be taken to the Functions Management Page for the selected agent.
Viewing Existing Functions
The Functions page displays a table of all functions associated with the agent.
Each function row includes:
- Function Name – Unique identifier for the function
- Type – WhatsApp / API / CSV / Shopify
- Description – Purpose of the function
- Template – Linked WhatsApp template (if applicable)
- Actions – Edit or Delete options
This view helps you quickly audit and manage your automation capabilities.
Adding a WhatsApp Function
Step 1: Add Function
- Click Add Function
- From the dropdown, select WhatsApp Function
Step 2: Fill Function Details
-
Function Name
A unique, descriptive name (e.g.,send_order_update) -
Description
Short explanation of what the function does -
Pre-Tool Execution Message (Optional)
Message the agent says before executing the function
Example: “Let me send you the order update.”
Step 3: Select WhatsApp Template
- Choose an approved WhatsApp template
- Templates are fetched directly from your WhatsApp Business account
- Only approved templates can be used
Step 4: Configure Parameters
Define the parameters required by the selected template.
For each parameter:
- Key – Variable name (e.g.,
order_id,otp) - Example Value – Sample value for testing and clarity
These parameters are automatically filled by the agent at runtime.
Step 5: Save Function
- Click Save
- The WhatsApp Function is now available for use by the agent
Editing or Deleting Functions
Edit a Function
- Click the Edit icon next to the function
- Update details, template, or parameters
- Save changes
Delete a Function
- Click the Delete icon
- Confirm deletion to permanently remove the function
Using WhatsApp Functions
-
WhatsApp Functions can be triggered:
- In response to user messages
- As part of defined workflows
- By agent decision logic
-
When triggered:
- The agent fills template parameters
- The WhatsApp message is sent using the selected template
- Delivery follows WhatsApp Business rules and quality checks
Best Practices
- Use clear and descriptive function names
- Keep parameter keys simple and meaningful
- Always test functions with sample data before production
- Ensure templates remain:
- Approved
- Updated
- Compliant with WhatsApp policies
- Avoid creating multiple functions for the same purpose unless necessary
Summary
WhatsApp Functions are a powerful way to automate structured messaging and workflows for your WhatsApp Agent. By combining approved templates with dynamic parameters, you can deliver reliable, compliant, and scalable WhatsApp communication.
Use them thoughtfully to enhance automation while maintaining a high-quality user experience.
Troubleshooting
The WhatsApp function is configured but the agent never triggers it during conversations. The function description controls when the agent decides to use the function. Make the description more explicit: "Use this function when the user asks for an order confirmation, receipt, or booking summary to be sent via WhatsApp." Also confirm the function is saved and the agent has been updated after saving.
Template messages are failing with a delivery error. Verify the template status is Approved in your Meta Business Manager account. A single character mismatch in the template name, namespace, or language code will cause delivery to fail silently. Also confirm the recipient's phone number is registered on WhatsApp and that your WhatsApp Business account is in LIVE mode.
The agent is sending messages but placeholder values are showing as blank or "undefined".
Check that all template placeholder parameters are correctly mapped to function attributes. Each {{1}}, {{2}} placeholder in the template must have a corresponding populated attribute from the conversation context. Test the function with known data to verify the mapping is correct before going to production.
Frequently Asked Questions
Can the WhatsApp function send media messages (images, PDFs)? Yes, if the approved template includes a media header (image, document, or video). The media URL must be a publicly accessible link included as a template parameter. Plain text templates without a media header cannot send attachments.
Can I trigger a WhatsApp function proactively without the user asking? WhatsApp functions are triggered by agent decision logic during a conversation. You can configure the agent's instructions to proactively offer sending a summary or confirmation at a specific point in the flow — for example, after a booking is confirmed — without the user explicitly requesting it.
Is there a character limit for WhatsApp template messages sent via the function? WhatsApp template body text has a limit of 1,024 characters. Header text is limited to 60 characters. Design your templates within these limits. For longer content, consider using a document attachment in the template header instead of embedding all text in the body.
What happens if the WhatsApp message fails to deliver? Failed deliveries are logged in the agent's function call history. Common causes include: invalid phone number, recipient not on WhatsApp, template not approved, or account messaging restrictions. Review the error reason in the logs and correct the underlying issue before retrying.
Can I use the WhatsApp function to send messages to a different number than the one currently chatting? By default, the function sends to the phone number of the active WhatsApp session. To send to a different number, include the target phone number as an explicit function attribute and configure your backend or template parameters to route accordingly.
Related Articles