4 min readUpdated Mar 2, 2026

sendMessage Logic Documentation

Overview

The sendMessage functionality is designed to send messages via WhatsApp using the Meta platform. This component allows users to specify destination information, message content, and format in a straightforward, programmatic manner. It integrates deeply with the Meta API to facilitate communication using a specified contact number, enabling businesses to reach customers directly through a widely-used messaging platform.

Settings

The sendMessage logic accepts several configurable settings. Below is a detailed breakdown of each setting:

1. Recipient Phone Number (to)

2. Message Type (type)

3. Message Content (text)

4. Template Content (template)

How It Works

The sendMessage function executes the following steps:

  1. Input Validation: It first validates that a recipient phone number (to) is provided. If not, it returns an error message.
  2. Integration Setup: It constructs a connection instance to theMeta's API using the BuildConnectionInstance utility, passing the context for authentication and access rights.
  3. Resolve Phone Number: It leverages the integration to resolve the WhatsApp Phone Number ID linked to the given number. This is crucial for sending messages through the API accurately.
  4. Send Message: It then attempts to send the WhatsApp message using the integration's sendWhatsAppMessage method, supplying the destination, type, text, and template data as necessary.
  5. Error Handling: If any errors occur during this process, a user-friendly error message is returned detailing the issue encountered.

Upon successful message delivery, the function returns the output data received from the WhatsApp API.

Use Cases & Examples

Use Case 1: Automated Customer Notifications

A retail company can utilize the sendMessage logic to automatically notify customers about order confirmations, shipment updates, or promotions packaged in neat text or template messages.

Use Case 2: Appointment Reminders

A healthcare provider may use the sendMessage function to send appointment reminders to clients, thereby improving attendance rates and customer satisfaction.

Use Case 3: Two-way Communication

A tech support company can implement this logic to allow customers to send queries or feedback through WhatsApp, streamlining customer interaction and support ticket generation.

Example Configuration for Customer Notifications

To configure the sendMessage logic for an automated order confirmation, you might set it up as follows:

json
{
    "inputs": {
        "to": "+1234567890",
        "type": "text",
        "text": "Your order has been successfully placed! Thank you for shopping with us."
    },
    "config": {
        "to": "+1234567890",
        "type": "text",
        "text": "Your order has been successfully placed! Thank you for shopping with us."
    },
    "context": {
        "userId": "user_123",
        "sessionId": "session_456"
    }
}

In this example, a customer receives a direct WhatsApp message confirming their order. Notice how both inputs and config provide the necessary details for message composition, while the context maintains user-specific session information necessary for integration with other services.