---
title: "Health plan quote chatbot with Postgres memory and tools"
kind: "Kit"
category: "Business"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/347ad261-c399-43f7-be6f-d6c355030c3a"
updated: "2026-11-12"
---

# Health plan quote chatbot with Postgres memory and tools

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n chat in Portuguese for comparing company health insurance plans. An AI agent remembers each visitor in Postgres, finds the three cheapest plans in a MySQL table and can call two web APIs. A starter you fill with your own data.

Health plan quote chatbot with Postgres memory and tools is an n8n workflow in the Business category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow is a chat that helps visitors compare health insurance plans for companies, in Portuguese. A public chat takes the visitor’s message. If a front end sent the visitor’s profile, an agent saves it to memory first. A quote agent then answers, with the last thirty interactions from a Postgres table. It can search a MySQL table for the three cheapest plans by city, number of lives and the holder’s age, and it can call two web APIs. Thirteen nodes do the work, beside one sticky note.

### Who it suits

Insurance brokers and benefits platforms that already hold a table of plans and prices and want a chat on top of it. Skip it if you have no such table or API. This is a starter, and the tables, the two APIs and the agent’s instructions are yours to supply.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Insurance | Brokers | Let a visitor describe a company and get the cheapest matching plans | A broker’s site shows three plans for a twelve-life company, cheapest first. |
| Benefits | Platform teams | Answer plan questions from an operator information service | A platform’s chat looks up an operator’s details when a visitor asks. |
| Human resources | HR consultancies | Give clients a first look at group plan prices | A consultancy lets a client try ages and group sizes before a call. |
| Agencies | Builders of chatbots | Start a client project from a chat that already has memory and tools | An agency swaps in the client’s table and the two APIs. |

You need solid n8n and a database for this one: three kinds of credential, a MySQL table with a set of columns and two APIs of your own. The workflow’s own sticky note gives no setup time.

### Where to use it

Any n8n that can reach OpenAI, a Postgres database and a MySQL database will run it. The chat opens inside n8n until you publish it and share the chat address.

- n8n Cloud: import the file into a new workflow there
- Your own n8n server: the same file and steps
- Your own site: post the visitor’s message, a \`leadData\` profile and a \`session\_id\` to the chat’s webhook from your front end
- Another market: change the table, the query and the system messages

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Three accounts and two web addresses cover every step.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server of your own |
| OpenAI | An API key that can use \`gpt-5.6-terra\` |
| Postgres | A database for the chat memory, where \`aimessages\` is created if missing |
| MySQL | A \`Products\` table with the columns the query uses, and a user that can only read it |
| Web APIs | An address for each of the two tools, or a decision to delete them |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add an OpenAI credential and select it in `Profile Chat Model` and `Assistant Chat Model`.
3. Add a Postgres credential and select it in `Postgres Chat Memory` and `Postgres Chat Memory1`.
4. Add a MySQL credential for a read-only user and select it in `Products in Database`.
5. In `Knowledge Base`, replace `<YOUR_QUOTE_API_HOST>` with your quote service. In `External API`, replace `<YOUR_LOOKUP_API_HOST>` with your lookup service. With neither, delete the tool and its line in the system message.
6. Read the system messages of `Save Lead Profile` and `Quote Assistant` and rewrite them.
7. Save the workflow, open the chat with the Chat button and ask for a plan for a company, with a city, a number of lives and the holder’s age.

### How to use it

A visitor writes in the chat. The agent asks for what a tool needs, such as the city and the holder’s age, then searches the table and lists what it finds. From your own front end, a first message can also carry `leadData`, a profile the agent saves to memory.

What to change for a different result

| To change | Where |
| --- | --- |
| How the agent talks and what it must do | The system message in \`Quote Assistant\` |
| The profile sentence | The text in \`Edit Fields1\` |
| The query and its modality | \`Products in Database\` |
| The greeting | The initial message in \`Chat Trigger\` |
| The tools’ addresses and descriptions | \`Knowledge Base\` and \`External API\` |
| The models | \`Profile Chat Model\` and \`Assistant Chat Model\` |

### Example

A visitor writes that a company of twelve people in São Paulo needs a plan and that the holder is 35. The agent calls the table tool with the city, the state, twelve lives and the age.

The tool returns up to three plans, cheapest for that age first. The agent lists them in Portuguese with their prices. If the table has no match, it says so and does not invent a plan.

### For newcomers and experts

**If you are new.** n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. Here an agent is a node that decides which tool to call. Test with the Chat button, watch which tool the agent picks in the run, and compare its answer with your table.

**For experts.** Two agents share one memory table, and the tools are plain nodes.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`If\` | Checks that the message carries a \`leadData\` object | The second condition compares two empty values and always passes |
| \`Postgres Chat Memory\` | Memory for \`Quote Assistant\`, window of thirty | Its key is \`session\_id\` followed by \`sessionId\`, so send one of the two |
| \`Products in Database\` | A MySQL tool that runs a query with values the model fills in | The values are written into the SQL text, so use a read-only user |
| \`External API\` | An HTTP Request tool that sends a POST with a JSON body | It fills \`{name}\` and \`{birthdate}\`, the single-brace placeholders |

### Good to know

The Assistants steps were rebuilt, and the system messages are ours.

- Assistants: OpenAI’s deprecations page, read on 12 November 2026, gives 26 August 2026 as the shutdown of the Assistants API. Both steps are now AI Agents on \`gpt-5.6-terra\`. The author’s instructions were not in the file, so the two system messages are Mindket’s drafts to rewrite
- Profile: the built-in chat page sends no \`leadData\` and no \`session\_id\`. The profile step needs a front end of your own
- Memory key: \`Edit Fields2\` leaves out \`sessionId\`, so a front end that sends both ids would start a new memory on the next message
- SQL: the table tool writes model-filled values into the query. Use a user that can only read the one table
- Public chat: anyone with the address can talk to the agent and spend your key
- Privacy: the profile is stored in Postgres and sent to OpenAI, and \`External API\` sends a name and a birth date to your service. Check your duties, for example under Brazil’s LGPD
- One business: the modality is fixed to \`PME\` and the state in \`Knowledge Base\` to \`SP\`
- Billing: each reply can mean several model calls
- Credentials: the JSON holds none

## README

```markdown
# Health plan quote chatbot with Postgres memory and tools

An n8n chat in Portuguese for comparing health insurance plans for companies. An AI agent remembers each visitor in a
Postgres table. It can search a MySQL table of plans for the three cheapest matches by city, number of lives and the holder's
age, and it can call two web APIs. It is a starter: the tables and the two APIs are yours to supply, and the two system
messages are short drafts to rewrite.

## What is inside

- `workflow.json`: the workflow as n8n exports it, thirteen nodes and one sticky note. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- The two steps that called an OpenAI Assistant used n8n's Assistant node. OpenAI's deprecations page, read on 12 November 2026,
  gives 26 August 2026 as the shutdown of the Assistants API, with the Responses API and Conversations API as the replacement.
  Both are now AI Agents, `Save Lead Profile` and `Quote Assistant`, each with a model node on `gpt-5.6-terra`:
  `Profile Chat Model` and `Assistant Chat Model`.
- The author's assistants held their own instructions, which are not in the file. The two system messages are ours. A short one
  saves the visitor's profile and confirms in one line. The other tells the quote agent to answer in Portuguese, use its three
  tools and quote only what a tool returns. Read both and rewrite them for your business.
- The tool `Products in Daatabase` is now `Products in Database`, and its description was written for it.
- The description of `Knowledge Base` was filler text. It now says what the tool looks up. Its address pointed at the
  author's company, and it is now `https://<YOUR_QUOTE_API_HOST>/widget/info`.
- `External API` called a private host. It is now `https://<YOUR_LOOKUP_API_HOST>/findByNameAndBirthDate`. Its body wrote
  `{{json.name}}`, which n8n reads as an expression and cannot resolve. It now uses `{name}` and `{birthdate}`, the single-brace
  placeholders an HTTP Request tool fills.
- The chat's greeting named the author's company and a bot. It is now a neutral Portuguese greeting.
- The OpenAI, MySQL and Postgres nodes lost their links to credentials in the author's n8n. Select your own.
- Nothing else. The file has no Code node.

## Before you start

- An n8n instance, on n8n Cloud or your own server.
- An OpenAI API key that can use `gpt-5.6-terra`.
- A Postgres database for the chat memory. The table `aimessages` is created on first use when it does not exist.
- A MySQL database with a table `Products`, and a user that can only read it. The query uses these columns: `cityQuery`,
  `state`, `modality`, `removed`, `minLifeAmount`, `maxLifeAmount`, `createdAt` and ten price columns from `priceAtAge0To18` to
  `priceAtAge59To199`.
- An address for each of the two web tools, or a decision to delete them.
- Your own web page or app, if you want the visitor's profile saved. See the notes below.

## Set it up

1. In n8n, create a workflow, open its menu and choose Import from File. Pick `workflow.json`.
2. Add an OpenAI credential and select it in `Profile Chat Model` and `Assistant Chat Model`.
3. Add a Postgres credential and select it in `Postgres Chat Memory` and `Postgres Chat Memory1`.
4. Add a MySQL credential for a read-only user and select it in `Products in Database`.
5. In `Knowledge Base`, replace `<YOUR_QUOTE_API_HOST>` with your quote service. In `External API`, replace
   `<YOUR_LOOKUP_API_HOST>` with your lookup service. If you have neither, delete the tool and its line in the system message of
   `Quote Assistant`.
6. Read the system messages of `Save Lead Profile` and `Quote Assistant` and rewrite them.
7. Save the workflow, open the chat with the Chat button on the canvas and ask for a plan for a company, with a city, a number
   of lives and the holder's age.

## How a run goes

1. `Chat Trigger` takes a visitor's message. It is public, and it opens with a Portuguese greeting.
2. `If` checks whether the message carries a `leadData` object. Without one, the message goes straight to `Quote Assistant`.
3. With one, `Edit Fields1` turns the profile into a sentence: name, age, city, state, profession, education, entity, device,
   channel and plan type. `Save Lead Profile` stores it in memory and confirms in one line.
4. `Edit Fields2` puts the visitor's own message and `session_id` back, and passes them to `Quote Assistant`.
5. `Quote Assistant` answers with `Postgres Chat Memory`, which keeps the last thirty interactions. It can call
   `Products in Database`, `Knowledge Base` and `External API`.
6. `Products in Database` returns the three cheapest plans in the modality `PME` for the city, state, number of lives and the
   holder's age, newest first among equal prices.
7. The reply goes back to the chat.

## Change the look

- How the agent talks and what it must do: the system message in `Quote Assistant`.
- The profile sentence: the text in `Edit Fields1`.
- The query: `Products in Database`, including the modality and the number of results.
- The greeting: the initial message in `Chat Trigger`.
- The tools' addresses and descriptions: `Knowledge Base` and `External API`.
- The models: `Profile Chat Model` and `Assistant Chat Model`.

## Good to know

- The profile branch needs a front end of your own. The built-in chat page sends no `leadData` and no `session_id`, so the
  workflow skips the profile step and goes straight to `Quote Assistant`. A front end can post both fields at the top level of its
  request to the chat's webhook.
- The memory key joins `session_id` and the chat's own `sessionId`. `Edit Fields2` leaves `sessionId` out, so a front end that
  sends both would start a new memory on the next message. Send one of the two ids.
- `Products in Database` writes values the model fills in straight into its SQL text. Give it a user that can only read the
  one table, and think about moving the values into the node's query parameters before real use.
- The chat is public. Anyone who knows its address can talk to the agent and spend your OpenAI key.
- The profile holds a person's name, age, city, profession and education, and it is stored in Postgres and sent to OpenAI.
  `External API` sends a name and a birth date to your lookup service. Check what your privacy duties allow, for example
  under Brazil's LGPD.
- The query and the tools are tuned to one business: the modality is fixed to `PME`, and the state in `Knowledge Base` is fixed
  to `SP`. Change them for yours.
- The quote agent is told never to invent a plan or a price. Still, test it against your own table before a visitor sees it.
- Each reply can mean several model calls, one for each tool the agent uses.
```

## What is in it

3 files, 21 KB, downloaded as a zip.

```text
NOTICE.md  642 B
README.md  7 KB
workflow.json  13 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: 6 steps, starting on a chat message
- AI: 2 steps call an AI model: Quote Assistant and Save Lead Profile
- Sign-ins: Signs in to: Postgres and OpenAI
- API keys: No API key is left in the file
- Step types: Mindket’s checker reads 3 of its 4 step types. It does not read: AI Agent

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/347ad261-c399-43f7-be6f-d6c355030c3a)
- [Its page on Mindket](https://mindket.com/p/347ad261-c399-43f7-be6f-d6c355030c3a)
