Automation library · AI assistants

Build a Headless AI Chat API with Memory and History

Started by another system calling it, and works across n8n data table. It hands the judgement calls to Groq. 26 steps, 1 branch: large, and worth reading before you trust it with anything live.

LargeCalls a model: Groq

26 stepsLarge: read it before trusting it with anything live
1Branch: places the flow splits
0Loops or waits
1Service it connects to

The flow

Starts it 6Model 4Logic 6Service 10

The steps in the order they run, from what starts it.

  1. 1Receive ChatWebhookStarts it
  2. 2Joke ToolHttp Request ToolService
  3. 3Get Convos WebhookWebhookStarts it
  4. 4Get History WebhookWebhookStarts it
  5. 5used to create the conversations table, RAN ONLY ONCE !Data TableService
  6. 6LLMLm Chat GroqModel
  7. 7LLM1Lm Chat GroqModel
  8. 8CRITICAL: CLEAN DBData TableService
  9. 9Parse InputCodeLogic
  10. 10Generate ReplyAgentModel
  11. 11Fetch User ConvosData TableService
  12. 12Fetch Full HistoryData TableService
  13. 13Summarize conversationChain LlmModel
  14. 14Check ExistsData TableService
  15. 15Save AI MsgData TableService
  16. 16Format Convo ListCodeLogic
  17. 17Format OutputCodeLogic
  18. 18Is Existing?IfLogic
  19. 19Send ResponseRespond To WebhookStarts it
  20. 20Send Convos ResponseRespond To WebhookStarts it
  21. 21Send History ResponseRespond To WebhookStarts it
  22. 22Save User MsgData TableService
  23. 23Gen Conv IDCodeLogic
  24. 24Fetch HistoryData TableService
  25. 25Save New MsgData TableService
  26. 26Format HistoryCodeLogic

How it's built

Starts on
Another system calling it
Steps
26, with 1 branch
Size
Large: read it before trusting it with anything live
Connects to
n8n data table
Model
Groq

Questions

What does it need to run?

An n8n account, and a key for Groq. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls Groq. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 26 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

Before you run it

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 26 steps before you point it at anything that matters.