Documentation for getMessages Logic
Purpose
This node is designed to facilitate the retrieval of messages from the Meta WhatsApp Business API. It establishes a connection to the WhatsApp service, resolves the appropriate phone number identifier, and fetches the associated business profile data. This logic is particularly useful for applications and systems that require integration with WhatsApp for customer communications, providing seamless access to business messaging capabilities.
Settings
This node is relatively simple, with the following key components and settings:
1. inputs
- Input Type: Object
- Description: This setting serves as the container for any input parameters that may be needed. In this implementation, specific input data is not mentioned, but it could be modified in the future to pass parameters concerning what messages or chat characteristics to filter for.
- Default Values:
{}(an empty object)
2. config
- Input Type: Object
- Description: Similar to
inputs, this configuration object is intended to hold configuration settings that may influence the behavior or the parameters of the service. As implemented, specific configurations are not utilized, but this space allows for potential expansion based on future requirements. - Default Values:
{}(an empty object)
3. context
- Input Type: Object
- Description: The context parameter provides necessary contextual information, allowing the logic to access relevant integrations and services dynamically. In this case, it is used to establish the integration with the Meta WhatsApp service.
- Default Values:
{}(an empty object)
Integration Logic
The core of the logic revolves around two main function calls:
- the integration connection: This function establishes the connection with Meta’s APIs using the provided context.
- resolveWhatsAppPhoneNumberId: This method fetches the WhatsApp phone number ID related to the business.
Error Handling
In the event of an error during execution, an error message is returned, prefixed with 'Internal Error: Meta WhatsApp integration encountered an error: ', followed by the error message for clarity.
How It Works
- Establishing Connection: The logic starts by attempting to create an integration instance connecting to the Meta platform using a secure connection.
- Retrieving Phone Number ID: Once the connection is established, the function calls
resolveWhatsAppPhoneNumberIdto obtain the unique ID associated with the WhatsApp phone number. - Fetching Business Profile: The ID acquired is then used in
getWhatsAppBusinessProfile, which retrieves the business profile information linked to the specified WhatsApp number. - Error Handling: If any of the calls fail, the error is caught, and a descriptive error message is returned.
- Output: If successful, the acquired profile data is returned in an object with a key named
output1, containing the business profile retrieved.
Data Expectations
- Input Data: This logic currently does not specify any required data inputs, but it uses parameters defined in the context object to establish the required integration.
- Output Data: The output consists of a business profile object from WhatsApp, which includes various details regarding the business, such as name, status, profile picture, etc.
AI Integrations
This logic, in its current setup, does not explicitly integrate AI components; however, it can be extended to utilize AI functionalities such as sentiment analysis or automated response generation using the retrieved message data in conjunction with AI techniques.
Billing Impacts
This node does not inherently incur direct billing impacts; those would depend on:
- The usage of the Meta WhatsApp API, which may have associated costs based on the number of messages sent and business profile inquiries made.
- Additional services or functionalities that may involve AI integrations could incur fees depending on the analytics or processing applied.
Use Cases & Examples
Use Cases
- Customer Service Automation: Businesses can use
getMessagesto automate responses based on incoming WhatsApp messages, ensuring swift resolutions for customer queries. - Data Extraction for Reporting: Marketers can extract message data for further analysis to understand customer engagement and adapt strategies based on insights.
- Unified Messaging Platforms: Integrate WhatsApp messages within broader customer communication platforms, allowing for a consolidated view of customer interactions across channels.
Detailed Example
Use Case: Customer Service Automation
Configuration: To configure this node for a customer service solution, a developer may set up a streamlined process facilitating direct responses based on customer inquiries via WhatsApp.
Sample Configuration Data:
{
"inputs": {
"customerQuery": "How can I reset my password?"
},
"config": {
"responseType": "automated"
},
"context": {
"whatsappIntegration": {
"accessToken": "YOUR_ACCESS_TOKEN",
"businessId": "YOUR_BUSINESS_ID"
}
}
}In this scenario, the inputs or configurations could be expanded to trigger off specific customer queries (not shown in implementation) that would enable the system to fetch relevant data and return appropriate automated responses leveraging the messages retrieved by getMessages.