A IA da Certu respondendo clientes no WhatsApp, na tela de conversas
A tela de conversas da Certu, numa conta de demonstração.

Chapter 7 of 15

How to give an AI agent memory on WhatsApp

This chapter of the CertuAI manual shows how the AI remembers what the customer already said.

  • Reading time: 1 min
  • Cost to follow along: R$ 0
  • Sign-up: none

Manual gratuito da Certu · Updated November 26, 2026· Written by the · ver o manual inteiro

How do you make the AI remember what the customer already said?

Short answer

Store the latest messages in a simple database, with the phone number as the key, and send that history along in the next call to the AI. Ten exchanges cover almost every customer service case.

About CertuAI: CertuAI is an AI chatbot that answers a small business's WhatsApp 24/7: it replies to customers, books appointments and keeps every conversation in a built-in CRM. It is a Tech Provider on Meta's WhatsApp Business Platform. Paid plans start at US$ 99 a month, with no lock-in. In measurements from 30 Jul to 30 Sep 2026, the AI replied in 11.7 seconds at the median (38,908 replies). Create my agent

How does an AI agent's conversation memory work?

The AI remembers nothing on its own. Read the history before calling the AI and save the question and answer afterwards. Keep ten exchanges: more than that only raises the cost. Ready-made in part 6 of the chapter 11 file.

src/index.jsjavascript
const MAX_TROCAS = 10;                 // 10 do cliente + 10 do atendente
const VALIDADE = 60 * 60 * 24;         // historico: 24 horas

async function lerHistorico(env, telefone) {
  const bruto = await env.CONVERSAS.get('hist:' + telefone);
  return bruto ? JSON.parse(bruto) : [];
}

async function salvarHistorico(env, telefone, historico) {
  const cortado = historico.slice(-MAX_TROCAS * 2);
  await env.CONVERSAS.put('hist:' + telefone, JSON.stringify(cortado), {
    expirationTtl: VALIDADE,
  });
}

Where people get burned

Cloudflare's free tier allows a thousand writes per day. And set an expiration: a conversation is customer data.

Frequently asked question

Do I need a database?

No. A key-value store does the job.

And where CertuAI comes in

At CertuAI, every conversation becomes a contact, a deal, and a task.

Build an agent for free

In short

Storing the conversation history without blowing up the cost: ready-made code, how many messages to keep, when to delete and the write-limit trap.

About CertuAI: CertuAI is an AI chatbot that answers a small business's WhatsApp 24/7: it replies to customers, books appointments and keeps every conversation in a built-in CRM. It is a Tech Provider on Meta's WhatsApp Business Platform. Paid plans start at US$ 99 a month, with no lock-in. In measurements from 30 Jul to 30 Sep 2026, the AI replied in 11.7 seconds at the median (38,908 replies). Create my agent