Extract spend details (template) n8n Workflow Template

n8n workflow template · 21 nodes · Gmail

Extract spend details (template) is a free n8n workflow template that starts from the Gmail Trigger node and works with Gmail, Google Gemini, Google Sheets and Groq. It has 21 nodes, 6 of them AI nodes (Structured Output Parser, Google Gemini Chat Model, Groq Chat Model and Basic LLM Chain). To run it, you add your own credentials for Gmail OAuth2, Google Gemini (PaLM) API, Google Sheets OAuth2 and Groq API.

At a glance

Trigger
Gmail Trigger (Get invoice)
Nodes
21
Apps
Gmail, Google Gemini, Google Sheets and Groq
AI nodes
6
Credentials
4 types
Category
Email automation

Apps and integrations

  • Gmail
  • Google Gemini
  • Google Sheets
  • Groq

Node types used

  • Gmail Trigger
  • Extract from File
  • HTML
  • Split Out
  • Structured Output Parser
  • Google Gemini Chat Model
  • Google Sheets
  • Edit Fields (Set)
  • Switch
  • Groq Chat Model
  • Basic LLM Chain
  • Merge

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

B. Deal with the data

  1. Multiple payment info in one mail: input the "sender" of the emails that contain more than one payment info. e.g. credit card daily spend notification
  2. One payment info in one mail: input the "sender" of the emails that contain only one payment info. e.g. instant credit card spend notification
  3. Invoices: input the mails that contain one invoice in one mail

C. Get spend details and send to google sheet

  • Edit the output schema to fit your google sheet format
  • Edit the prompt to fit your needs

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

A. Get data

  • Set up labels in Gmail
  • Suggested using Gmail filters to move emails to labels automatically

Nodes in this workflow

The 21 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. Get invoice (Gmail Trigger)
  2. Get payment (Gmail Trigger)
  3. Extract invoice (Extract from File)
  4. Extract payment (Extract from File)
  5. HTML (HTML)".spend-table" here is an example when the email use "spend" html tags to display each spends. e.g. Spend 1 Spend 2
  6. Split Out (Split Out)
  7. Structured Output Parser1 (Structured Output Parser)
  8. Google Gemini Chat Model1 (Google Gemini Chat Model)
  9. Send (Google Sheets)
  10. Set data 0 (Edit Fields (Set))
  11. Set data 1 (Edit Fields (Set))
  12. Set data 2 (Edit Fields (Set))
  13. Invoice data (Edit Fields (Set))
  14. Payment data (Edit Fields (Set))
  15. Switch (Switch)
  16. Groq Chat Model (Groq Chat Model)
  17. Structured Output Parser (Structured Output Parser)
  18. Send1 (Google Sheets)
  19. Extract details1 (Basic LLM Chain)
  20. Merge (Merge)
  21. Extract details (Basic LLM Chain)

Credentials you need

  • Gmail OAuth2 – used by Get invoice and Get payment
  • Google Gemini (PaLM) API – used by Google Gemini Chat Model1
  • Google Sheets OAuth2 – used by Send and Send1
  • Groq API – used by Groq Chat Model

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us