Generador de facturas y entrega por Gmail
Generación de factura y notificación por correo basada en registros de Airtable
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
Airtable-nub7s[Compra por procesar]
style Airtable-nub7s stroke:#a170ff
GmailMesageComponent-m5njd[<div><img src="/_astro/gmail.CLxyIGOu.svg" style="height: 20px !important;width: 20px !important"/></div>Notificar por gmail]
style GmailMesageComponent-m5njd stroke:#a170ff
ParseData-lnctx[<div><img src="/_astro/braces.Djq0PW4_.svg" style="height: 20px !important;width: 20px !important"/></div>Parse Data]
style ParseData-lnctx stroke:#a170ff
Airtable-oaruy[Marcar como atendido]
style Airtable-oaruy stroke:#a170ff
Loop-v9i9s[Loop]
style Loop-v9i9s stroke:#a170ff
LoopEnd-0246r[Loop End]
style LoopEnd-0246r stroke:#a170ff
OpenAIModel-glwa8[<div><img src="/_astro/openAI.BhmuxEs3.svg" style="height: 20px !important;width: 20px !important"/></div>OpenAI]
style OpenAIModel-glwa8 stroke:#a170ff
AdvancedAgent-bbgal[Agent2]
style AdvancedAgent-bbgal stroke:#a170ff
Airtable-nub7s -.- Loop-v9i9s
linkStyle 0 stroke:#a170ff
Loop-v9i9s -.- ParseData-lnctx
linkStyle 1 stroke:#a170ff
LoopEnd-0246r -.- Loop-v9i9s
linkStyle 2 stroke:#a170ff
AdvancedAgent-bbgal -.- LoopEnd-0246r
linkStyle 3 stroke:#a170ff
ParseData-lnctx -.- AdvancedAgent-bbgal
linkStyle 4 stroke:#a170ff
GmailMesageComponent-m5njd -.- AdvancedAgent-bbgal
linkStyle 5 stroke:#a170ff
Airtable-oaruy -.- AdvancedAgent-bbgal
linkStyle 6 stroke:#a170ff
OpenAIModel-glwa8 -.- AdvancedAgent-bbgal
linkStyle 7 stroke:#a170ff
Generador de facturas y entrega por Gmail
🧩 Overview
This workflow automates the generation and delivery of invoices for pending sales orders. It extracts unprocessed sales records from an Airtable database, processes each order individually within a loop, and uses an AI agent to generate and send an invoice via Gmail to the customer. Finally, it updates the database to mark the order as completed, streamlining the billing and notification process.
⚙️ Main Features
- Automatically fetches unprocessed sales records from a specified Airtable base using a custom filter.
- Processes each sales record sequentially within a controlled loop structure.
- Utilizes an AI agent equipped with tools to generate and send personalized invoice emails.
- Updates the source database to reflect the completion status of each processed order.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Airtable (Compra por procesar) | Fetches all unprocessed sales records from the database. | Airtable base name, table name, and a filter formula (atendido="false"). |
A list of sales records that require processing. |
| Loop | Iterates over the list of unprocessed sales records, processing them one at a time. | The list of records from the Airtable component. | A single sales record for the current iteration. |
| Parse Data | Formats the raw sales data from the current record into a structured text message. | The individual sales record data (e.g., customer name, email, product details). | A formatted text message containing all relevant order information. |
| OpenAI Model | Provides the core language model that powers the AI agent's reasoning and text generation. | Model configuration (e.g., temperature, API settings). | A configured language model instance. |
| Gmail Message Component (Notificar por gmail) | Serves as a tool for the agent to send email messages. Configured to send messages. | Email recipient, subject, body, and attachments (when connected as a tool). | A tool interface for sending emails. |
| Airtable (Marcar como atendido) | Serves as a tool for the agent to update the database record. Configured for update operations. | The record ID and the field to update (e.g., atendido="true") (when connected as a tool). |
A tool interface for updating records. |
| Advanced Agent (Agent2) | The central AI agent that receives the formatted order data, decides on actions, and uses the provided tools to generate the invoice, send the email, and update the database. | The formatted order message, the language model, and the Gmail and Airtable tools. | The agent's final response after completing the task for the current order. |
| Loop End | Marks the end of the processing loop for one record, allowing the loop to proceed to the next item. | The agent's response from processing the current record. | The processed data, signaling the loop to continue or finish. |
🧠 Notes
- The workflow requires a pre-existing Airtable base with a specific table structure containing fields for customer name, email, product, quantity, unit price, total, status (
atendido), and order date. - The initial Airtable component is configured to filter and retrieve only records where the
atendidofield is set to "false". - The AI agent operates with a defined system prompt and has access to specific tools for email dispatch and database updates, which it uses autonomously.
- Proper credentials for Airtable, Gmail, and the OpenAI API must be configured for the respective components to function.
- The loop structure ensures each sales order is handled independently and in sequence.