SOLVD BLOG

How to use AI to perform real tasks in your n8n workflow (Part 3)

In the ongoing n8n automation series, we’ve progressed from triggering workflows with form submissions to extracting data from PDFs. Now, it’s time for the next leap: integrating artificial intelligence to analyze, summarize, and automate decisions with your extracted data using OpenAI models—all seamlessly within your n8n workflow.

What You’ll Learn

  • Sending extracted PDF data to OpenAI
  • Setting up a custom OpenAI Assistant
  • Practical use case: Automating commission statement aggregation

Bringing AI into Your n8n Workflow

In previous steps, you learned how to extract structured text and tables from PDFs—for example, insurance commission statements. The next step is to use AI to process this raw data, transforming it into actionable insights or structured outputs. This enables tasks like generating summaries, extracting key data points, or consolidating duplicate records—automatically.

Example Scenario: Commission Statement Aggregation

Suppose you’ve received a commission statement PDF where a customer, such as “Apex Logistics,” appears multiple times, each with different premium payments. You want to combine these into a single entry, summing up all premiums and commissions for each customer. Doing this manually would be tedious and error-prone—but with OpenAI and n8n, it becomes effortless.

Setting Up Your OpenAI Assistant

  • Understand Your Data: Know which file you’re uploading and your goal (e.g., aggregating financial figures for each customer).
  • Create an OpenAI Assistant:
    • Go to the OpenAI dashboard and create a new assistant.
    • Tailor its instructions for your specific task. For instance: “You are an expert data processor for insurance commission statements. You will receive JSON text as input data.”
  • Configure n8n Workflow:
    • Ensure the extract PDF node outputs the parsed data as JSON text.
    • Pass this JSON text as the prompt to the OpenAI assistant in n8n’s “Message an Assistant” node.
    • Add your OpenAI credentials and select your custom assistant.
    • You have the option to pass additional instructions, but often, the data and the clear assistant instructions are sufficient.

Execution and Results

When you execute the workflow:

  • n8n extracts the relevant information from your PDF and formats it as JSON text.
  • The OpenAI assistant receives this JSON, aggregates data (like summing all premium payments for each customer), and outputs it as a JSON list—one object per customer.
  • The output is ideal for downstream processes, such as creating records in Salesforce, exporting CSVs, or generating reports.

Important Note on Output Handling

OpenAI’s output is technically plain text, even if it’s formatted to look like a list of JSON objects. To loop through these records in subsequent workflow steps, you’ll need to parse this text into actual JSON objects using a conversion node or function within n8n.

What’s Next?

This automation setup paves the way for more advanced use cases—such as seamlessly creating Salesforce records from aggregated results. Stay tuned for the next installment, where we’ll show you how to format the AI assistant’s output into proper JSON and push it into your Salesforce environment!

yellow cloud solvd logo
Testimonials

Our clients say

From my initial call with Spencer through project implementation with John and Evan, my experience with the SOLVD team was excellent. They were quick to understand our business needs, clear when explaining the reasoning behind proposed solutions, transparent when reporting on progress and timeline, and all around enjoyable to work with. Would highly recommend and looking forward to continue working with them in the future!

Veronica Wong Director of Operations at Pathstream

SOLVD was very straight forward with everything needed to complete the project. No surprises, no issues, and cost was aligned with the estimate. They made implementation easy and quick.

Matt Benzaquen Sr Manager, Sales Strategy at Instabug

As a rule, I'm pretty stingy with my recommendations. So it's a pleasure for me to recommend Solvd as a top-flight Salesforce consultancy. Solvd recently led our company's conversion to the Lightning interface and did it on time, on budget and made it easy for me and my team. I know I'll use their services again, and am confident they can do the same for you.

Tim Tuttle CFO at Relevate Health Group

HIGHEST RATED ON SALESFORCE