WhatsApp Media Processor icon

WhatsApp Media Processor

Processa mídia do WhatsApp usando OpenAI

Overview

This node, named "WhatsApp Media Processor," is designed to handle and process WhatsApp messages and media content automatically. It supports multiple operations including:

  • Automatic Message Grouping: Collects and groups multiple messages from the same phone number within a specified waiting time, consolidating them into a single message output.
  • Message Splitting: Divides a long text message into smaller parts based on a word limit, associating each part with a phone number.
  • Media Processing: Processes different types of WhatsApp media such as text, audio, images, and PDF documents using OpenAI services for transcription, image analysis, and text extraction.

Practical Use Cases

  • Customer Support Automation: Automatically group fragmented customer messages sent in quick succession to provide a coherent context for support agents or automated systems.
  • Content Moderation or Analysis: Split large messages into manageable chunks for easier processing or moderation.
  • Media Content Understanding: Transcribe audio messages, analyze images, or extract text from PDFs received via WhatsApp to automate workflows like ticket creation, sentiment analysis, or data entry.

Properties

Name Meaning
Número de Telefone Phone number of the client sending the message (used for grouping or splitting messages).
Mensagem The message content received from the client (text to be grouped or split).
Tempo de Espera (segundos) Waiting time in seconds to accumulate and group messages from the same phone number.

These properties are specifically used when the operation selected is "Agrupar Mensagens Automático" (Automatic Message Grouping).

Output

The node outputs an array of JSON objects where each object contains:

  • phone: The phone number associated with the grouped or processed message.
  • message: The resulting message after processing, which could be:
    • A concatenated string of grouped messages (for automatic grouping).
    • Individual message parts (for splitting).
    • Transcribed text from audio.
    • Descriptions or extracted text from images.
    • Extracted text from PDF documents.
    • Plain text messages if no media processing is needed or enabled.

If media processing is involved, the output message field contains the processed textual content derived from the media.

The node does not output binary data directly; media files are downloaded and processed internally, with results returned as text.

Dependencies

  • OpenAI API: Used for audio transcription (Whisper model), image analysis (GPT-4 Vision and variants), and other AI-powered processing.
  • WhatsApp Business API: Required to fetch media URLs and download media content.
  • PDF Parsing Library: For extracting text from PDF documents.
  • Axios HTTP Client: For making HTTP requests to external APIs.

Required Configurations

  • An API key credential for OpenAI services.
  • Credentials containing WhatsApp Business ID and WhatsApp API Key for accessing media URLs and downloading media.

Troubleshooting

  • Invalid Webhook Format: If the incoming webhook data does not contain expected message structures, the node throws an error indicating an invalid webhook format. Ensure the webhook payload matches WhatsApp's expected structure.
  • Media Not Found or Expired URL: Errors may occur if the media URL is missing or expired. This can happen if the WhatsApp media link is no longer valid. Retry fetching the media or ensure timely processing.
  • Unsupported Media Type: If a media type other than text, audio, image, or PDF is received, the node will throw an unsupported media type error.
  • Disabled Processing Options: If processing for a specific media type (text, audio, image, PDF) is disabled, the node returns a message indicating that processing is turned off for that type.
  • Missing Credentials: Errors related to missing WhatsApp Business ID or API keys indicate misconfiguration of credentials required for media access.
  • API Response Issues: Invalid or unexpected responses from OpenAI API calls may cause errors. Verify API keys and usage limits.

Links and References

Discussion