IntegrationsIntermediate

How to Give a Zapier AI Webhook Simple Conversation Memory

Use Storage by Zapier to remember the last few turns so your AI replies stay in context across webhook calls.

10 minIntermediate

A plain webhook to an AI model forgets everything between calls, so a chatbot built that way cannot follow up on what was said earlier. Storage by Zapier gives you a tiny key-value store. By keying it on a user id you can stash recent turns and feed them back into the next prompt.

What you need

  • A Zapier account with Storage by Zapier and Webhooks by Zapier
  • An OpenAI API key
  • A client that sends a stable userId with each message

Step 1: Catch the message

Use a Catch Hook trigger that receives userId and message. The userId is the key that keeps each person's history separate.

Step 2: Read prior history

Add a Storage by Zapier action with the Get Value event. Use a key like history-{{userId}} so each user has their own slot. On the first message this returns empty, which is fine.

Zapier - Storage by Zapier
Action: Storage by Zapier
Event: Get Value
Key: history-{{userId}}
Returns: 'User: hi | AI: hello, how can I help?'
Get the stored history for this user before the model call.

Step 3: Include history in the prompt

In the OpenAI step, paste the retrieved history into the system or user content so the model has the recent context, then add the new message.

OpenAI request body
{
  "model": "gpt-5-mini",
  "messages": [
    { "role": "system", "content": "Conversation so far:\n{{history}}" },
    { "role": "user", "content": "{{message}}" }
  ]
}

Step 4: Write the updated history back

After the model replies, add a Storage Set Value action on the same key. Concatenate the old history, the new user line, and the AI reply so the next call sees it.

Cap the size
Storage values have length limits and long histories cost more tokens. Keep only the last few turns, for example by trimming to the most recent 1500 characters before you save.
bash - two turns, same user
$curl ... -d '{"userId":"u1","message":"My name is Sam"}'
{"reply":"Nice to meet you, Sam!"}
$curl ... -d '{"userId":"u1","message":"What is my name?"}'
{"reply":"Your name is Sam."}
$

Result: the second call remembers the name from the first, because the history round-trips through Storage between requests.

Watch related tutorials

Tags
#zapier#memory#openai#storage