Project Summary - MEBYA to automate incoming invoices in Excel (Google Sheets) with the open source workflow automation platform n8n
Resumen del proyecto-MEBYA para automatizar facturas entrantes en Excel (Google Sheets) con la plataforma n8n de automatización de flujos de trabajo de código abierto

Esquema | Scheme

AI Agent

1) Gmail Trigger | Activador de Gmail


2) Input -> Edit Fields (Set) | Editar campos (establecer)

Context Mail: | da contexto del email

Sender email address: | Dirección de email del remitente

mauricio@gmail.com

Email subject: | Asunto del email

invoice

Email body: | cuerpo del email

aca esta la factura


3) AI Agent (Tools Agent)| Agente IA (Agente de herramientas)

Your role is as a sorting receptionist for the XYZ company. You must

determine if the email is related to the company's billing department.

Traducción:

Su función es la de recepcionista de clasificación para la empresa XYZ. Debe determinar si el correo electrónico está relacionado con el departamento de facturación de la empresa.

- OpenAI Chat Model -> gpt-4o-mini

- Structured Output Parser | Analizador de salida estructurada

{

"type": "object",

"properties": { "isInvoice": { "type": "boolean" },

"invoicetype": { "type": "string" },

"reasoning": { "type": "string" },

"name_company": { "type": "string" }

},

"required": ["isInvoice", "reasoning"]

}


4) IF (condicional) -> Invoice?

Analyze whether or not it is an invoice

Traducción: Analiza si es o no una factura

--->If is yes | Si es si

Action 1/2 | Accion 1

Gmail - Add Label | Agregar etiqueta -> Billing | Facturación

Action 2/2 | Accion 2

Gmail - Get message | Obtener mensaje

& -> Download Attachments | Descargar archivos adjuntos

--->If no | Si es no

No Operation, do notthing | No hace nada


5) Edit Fields (Set) | Editar campos (establecer)

Get ID_Gmail + PDF Extractor

Obtiene el ID del email


6) Merge | Unir -> ID_Gmail + PDF Extractor


7) Aggregate | Agregar a un mismo Objeto JSON

All Item Data (Into a Single List)

Todos los datos del artículo (en una sola lista)


8) Edit Fields (Set) | Editar campos (establecer) MANUAL

Extracted PDF data | Datos PDF extraídos

-> name_company

-> text


9) Edit Fields (Set) | Editar campos (establecer) MANUAL

PDF message Data

-> Sending company | Empresa de envío

-> Text invoice | Factura de texto


10) AI Agent1

Extracts the data from this invoice and returns the response in JSON object format following the following structure:

Extrae los datos de esta factura y devuelve la respuesta en formato de objeto JSON siguiendo la siguiente estructura:

{

"output":

{

"invoiceIssueDate": "string",

"expirationDate": "string",

"invoiceNumber": "string",

"issuingCompany: "string",

"taxBase": number,

"appliesVAT": boolean,

"percentageVAT": number,

"amountVAT": number,

"total": number

}

}

Tools Agent1| Herramientas del Agente1

- OpenAI Chat Model1

- Structured Output Parser1 | Analizador de salida estructurada1

{

"type": "object",

"properties": {

"invoiceIssueDate": {

"type": "string",

"description": "Date of issue of the invoice, in DD-MM-YYYY format"

},

"expirationDate": {

"type": "string",

"description": "Invoice due date, in DD-MM-YYYY format"

},

"invoiceNumber": {

"type": "string",

"description": "Issued invoice number"

},

"issuingCompany": {

"type": "string",

"description": "Name of the company that sends the invoice."

},

"taxBase": {

"type": "number",

"description": "Taxable base or subtotal of the invoice."

},

"appliesVAT": {

"type": "boolean",

"description": "Indicates whether VAT is applied to the invoice."

},

"percentageVAT": {

"type": "number",

"description": "Percentage of VAT applied (e.g. 21 to 21%)."

},

"amountVAT": {

"type": "number",

"description": "Total VAT amount calculated"

},

"total": {

"type": "number",

"description": "Total of the invoice taking into account withholdings and other adjustments. (e.g. taxable rate + VAT)."

}

},

"required": [

"invoiceIssueDate",

"expirationDate",

"invoiceNumber",

"issuingCompany",

"taxBase",

"appliesVAT",

"percentageVAT",

"amountVAT",

"total"

]

}


11) Edit Fields (Set) | Editar campos (establecer) MANUAL

Excel Data Invoice

[

{

"invoiceIssueDate": "31-01-2025",

"expirationDate": "31-01-2025",

"invoiceNumber": "5163848351",

"issuingCompany": "Google LLC",

"taxBase": 12,

"appliesVAT": false,

"percentageVAT": 0,

"amountVAT": 0,

"total": 12

}

]


12) Google Sheets -> Append Row | Agregar fila

[

{

"Invoice Issue Date": "31-01-2025",

"Expiration Date": "31-01-2025",

"Invoice Number": "5163848351",

"Issuing Company": "Google LLC",

"Tax Base": 12,

"Applies VAT": false,

"Percentage VAT": 0,

"Amount VAT": 0,

"TOTAL": 12

}

]




Powered by MEBYA