Tutor English chat messages using OpenRouter with Postgres memory and log to Supabase
Go to WorkflowDescription
Quick overview
This workflow receives English practice messages via a webhook, uses an OpenRouter chat model with Postgres-backed conversation memory to generate tutoring feedback, logs the exchange to Supabase, and returns the tutor’s reply as a JSON response.
How it works
Receives a POST webhook request containing a user_id and message.
Extracts and standardizes the incoming fields so the workflow has clean user_id and message values.
Sends the message to an AI English tutor powered by OpenRouter, using Postgres chat memory keyed by user_id to maintain per-student context.
Logs the tutor output to a Supabase conversations table along with the user identifier and original message.
Returns a JSON response to the caller containing the tutor’s reply.
Setup
Add an OpenRouter API credential and (optionally) choose a different model in the OpenRouter chat model configuration.
Add Postgres credentials and ensure the database is reachable from n8n so chat memory can persist sessions by user_id.
Add Supabase credentials and create a conversations table, then confirm the mapped columns (user_id, role, message) match your schema.
Copy the webhook URL from n8n and configure your app to POST a JSON body with user_id and message to that endpoint.