5 min read

getTemplates Documentation

Overview

This node is designed to fetch templates from the Meta WhatsApp platform. It is especially useful for applications that require dynamic handling of WhatsApp messaging templates. This logic connects to the WhatsApp Business API, retrieves the specified templates, and formats the data for further use.

Purpose

The primary purpose of getTemplates is to enable applications to interact with WhatsApp templates, such as retrieving their metadata (like status and category) and managing WhatsApp business communication more effectively. It serves as an integration point that simplifies data retrieval from the WhatsApp API.

Settings

This node contains configurable settings which allow users to tailor its behavior according to their needs. Below are the detailed explanations of each setting:

1. fields

2. limit

3. inputs

4. config

5. context

How It Works

  1. Input Handling: The logic begins by retrieving the fields and limit from either the inputs or config objects, defaulting to the preset values if they are not provided.

  2. Integration Initialization: It establishes a connection to the Meta WhatsApp API through the the integration connection function, which is crucial for performing actions within the WhatsApp ecosystem.

  3. Business Account Resolution: The logic calls for the business account ID linked to the WhatsApp service using the integration object, which is necessary to authenticate and perform template retrieval.

  4. Data Fetching: It invokes getWhatsAppTemplates, passing the resolved business account ID, specified fields, and limit to fetch the required templates.

  5. Error Handling: If any errors occur during the process (e.g., API connection issue), it catches them and returns an error message.

  6. Output Formatting: Successfully retrieved data is returned in a structured format, indicating the data and paging.

Data Expectations

This node expects the following data structure from the calling environment:

AI Integrations

As of the current implementation, there are no direct AI integrations associated with this node. However, since it interacts with an external API, it could be utilized in conjunction with AI features such as sentiment analysis on template messages or analytics on template performance.

Billing Impacts

The use of this node may have an impact on billing in scenarios where:

Use Cases & Examples

Use Case 1: Marketing Campaign Management

A business regularly sends promotional messages through WhatsApp. They need to ensure that their messaging aligns with the latest templates provided by WhatsApp, including language variations and content categories.

Use Case 2: Customer Support

A customer service team uses WhatsApp for live chat and needs to display updated available message templates to respond to customer inquiries effectively.

Use Case 3: Template Performance Monitoring

A project team wants to analyze the performance of their messaging templates (e.g., open rates) and needs a way to retrieve the metrics corresponding to each template.

Detailed Example

Business Context:

A retail company is running a marketing campaign via WhatsApp. They want to retrieve and display available promotional templates for their customer support team to ensure they properly can inform customers about current offers.

Configuration:

javascript
const configuration = {
    inputs: {
        fields: ['id', 'name', 'status', 'category'],
        limit: 10
    },
    config: {},
    context: {
        userAuthToken: 'abc123xyz' // authentication token for the Meta WhatsApp API
    }
};

const result = await getTemplatesNode(configuration);
console.log(result);

Explanation:

This setup efficiently retrieves the relevant templates while adhering to the company's operational needs and limitations.