n8n

How to Streamline OpenAI MySQL Product Recommendations?

Give your site a smart sales chat that pulls real product info and answers in plain language. It reads what a buyer needs, checks your database, and shares clear options without switching tools. Ideal for teams that quote plans by city and company size.

Conversations start from a public chat trigger. A short intro message seeds the memory, then the main assistant takes over with long chat memory saved in PostgreSQL. The assistant can call three tools by itself: a MySQL product search, a knowledge base HTTP endpoint, and an external person lookup by name and birthdate. The MySQL query filters by city, state, and modality, and ignores removed items. Variables like cityQuery, state, and holderCount are inferred from the user message, so plain text questions still return exact matches. Set and If nodes route the first message correctly, while two OpenAI assistant nodes handle memory scope and tool use.

Connect OpenAI, PostgreSQL, and MySQL, then align the product query with your table names. Expect faster replies, fewer errors, and more consistent pricing help across agents. Great for pricing guidance, plan comparisons, and prequalification before a human closes the deal.

What are the key features?

  • Public chat trigger starts a session that users can access from a link or widget.
  • Two-stage memory design: a one-message seed for persona and a 30-message history for real conversations saved in PostgreSQL.
  • OpenAI assistant calls tools on its own to search products, read knowledge pages, and verify people by name and birthdate.
  • MySQL tool runs a parameterized query by city, state, modality, and holder count while skipping removed items.
  • Knowledge base HTTP tool fetches plan and pricing info from a dedicated endpoint using simple URL parameters.
  • External HTTP POST checks a person by name and birthdate using a clean JSON body.
  • If and Set nodes route and format the first message to keep memory clean and consistent.

What are the benefits?

  • Reduce manual product search from 10 minutes to 2 minutes per chat
  • Automate up to 70% of routine pricing questions with AI tools
  • Improve data accuracy by 90% by answering from a single source of truth
  • Handle 5 times more simultaneous chats using stored conversation memory
  • Connect three data sources in one place for faster answers

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with OpenAI, PostgreSQL and MySQL. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, create an OpenAI API Key credential. Get your API key from your OpenAI account and paste it into the API Key field. Save the credential and select it in both OpenAI nodes.
  4. Create a PostgreSQL credential that points to the database used for chat memory. Provide host, database, user, password, and SSL if needed. Ensure the user can read and write to the aimessages table.
  5. Create a MySQL credential that can read your product database. Use a read-only user for security. Test the connection to confirm access.
  6. Open the Chat Trigger node and keep it public. Copy the webhook URL for testing in your browser or chat widget.
  7. Open the Products in Daatabase node. Align the SQL with your schema. Check column names like cityQuery, state, modality, removed, and any holder count math. Run a test query with sample values.
  8. Open the Knowledge Base HTTP tool. Confirm the base URL and that the placeholders for modality, state, city, and operator match your system. Use the node’s test to verify a valid JSON response.
  9. Open the External API HTTP tool. Keep method as POST and ensure the JSON body contains name and birthdate in the required format. Send a test payload to see a valid response.
  10. Verify both Postgres Chat Memory nodes point to the same aimessages table. Confirm one has context length 1 and the other 30. Make sure the session key expression uses the chat session id.
  11. Click Execute on the Chat Trigger test URL and send a message that includes city, state, and team size. Check the execution to confirm the AI called the MySQL tool and returned matching products.
  12. If tools are not called, check the OpenAI2 node tool connections, ensure credentials are selected, and confirm the $fromAI variables in the SQL match the assistant’s expected field names.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

MySQL

Sign up

MySQL Community Edition (GPL) – Free ($0)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.