n8n

How to Connect Supabase Gemini Chat Support?

Build a chat assistant that remembers each conversation and keeps contact data clean. It stores chat history in a Supabase table and fills missing name fields automatically. Great for support teams testing WhatsApp style chats or early CRM capture.

When you click Test workflow, a Set node loads a sample session id, name, and chat text. An Agent uses Google Gemini Flash 2.0 and pulls up to 20 past messages from a Supabase Postgres chat memory using that session id. The Agent sends a reply and the memory node logs the turn to the whatsapp_messages3 table. After that, a Supabase API step finds rows where the session id matches and the name is empty, then writes the name from the input. You get context for each user and cleaner records in one run.

You will need a Supabase project with a table named whatsapp_messages3 and a Google Gemini API key. Connect the Postgres chat memory and the Supabase API credential, then set the sample inputs. Expect faster answers, less manual data entry, and tidier profiles for support, lead intake, and internal help chat pilots.

What are the key features?

  • Manual test run to safely validate the flow before going live
  • Set node defines session_id, name, and chatInput as the starting data
  • Google Gemini Flash 2.0 generates helpful replies for each message
  • Postgres chat memory in Supabase stores and retrieves up to 20 past turns per session
  • Agent node uses a simple system message to keep responses on track
  • Supabase API update fills the name field only when it is empty for the same session

What are the benefits?

  • Reduce manual profile updates from 1 hour a day to 5 minutes by auto filling missing names
  • Give agents instant context by auto loading the last 20 messages for each session
  • Improve contact data completeness by up to 90% with conditional name updates
  • Unify AI replies and stored history by connecting Gemini with Supabase
  • Handle more concurrent chats as history scales in a database instead of flat files

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 Google Gemini and Supabase. See the Tools Required section above for links to create accounts with these services.
  3. In Supabase, create a project and a database. Add a table named whatsapp_messages3 with at least these columns: session_id (text) and name (text). Add other message columns as needed for your chat history.
  4. Open the node named Supabase Postgres Database. In the credentials dropdown, click Create new credential. Choose a Postgres connection and enter your Supabase host, port, database, user, and password. Save the credential.
  5. In the Supabase API update node, click the credential dropdown and Create new credential. Select Supabase API, paste your Supabase URL and service role key or anon key with write access, then save.
  6. Open the GeminiFlash2.0 node. In the credential dropdown, click Create new credential. Follow the on screen steps to add your Google Gemini API key from the Google AI Studio API page.
  7. Open Set sample Input Variables. Enter a real session_id, a display name, and a chatInput message to test. Keep session_id consistent across runs to see memory in action.
  8. Review the Sample Agent. Confirm the system message fits your tone. Make sure it is connected to the Gemini language model and the Supabase Postgres chat memory.
  9. Run the workflow with Test. Check the response in n8n, then open your Supabase table to confirm new rows were added and the name field was updated when previously empty.
  10. If the name does not update, confirm the update filters include session_id equals your test value and name is NULL. Check Supabase Row Level Security and API key permissions allow updates.
  11. To move beyond testing, replace the manual trigger with your real inbound source such as a webhook from your chat platform. Keep the same session_id logic so memory stays linked per user.

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.

Google Gemini

Sign up

Free tier: $0 via Gemini API; e.g., Gemini 2.5 Flash-Lite free limits 1,000 requests/day (15 RPM, 250k TPM). Paid from $0.10/1M input tokens and $0.40/1M output tokens.

Supabase

Sign up

Free: $0 / mo — unlimited API requests; 500 MB database; 5 GB bandwidth; 1 GB storage; 50,000 MAUs.

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.