Chat Memory
Chat Memory reads the message history of a conversation: what the user wrote and what the assistant answered. By default it uses the history NappAI keeps for your flows, but it can also read it from an external memory you connect.
Use it when a step in the flow needs to know what was said before, for example so a model can answer with context or to summarize a conversation.
When to use it
- Give an AI model the customer’s latest questions so its answer takes into account what was already discussed.
- Summarize a support conversation when it closes.
- Review only the messages the user wrote to detect their intent.
- Read the history stored in an external memory service.
Configuration
| Field | What it does |
|---|---|
| External Memory | Optional. Connect a memory component here if the history lives in an external service. If you leave it empty, the history NappAI keeps is used. |
Advanced options
| Field | What it does |
|---|---|
| Sender Type | Whose messages you want: Machine (the assistant’s answers), User (what the user wrote) or Machine and User (both, the default). |
| Sender Name | Filter by the sender’s name. |
| Number of Messages | How many of the most recent messages to retrieve. The default is 100. Order only changes how they are listed. |
| Session ID | The session whose history you want to read. |
| Conversation ID | The conversation whose history you want to read. |
| Order | Ascending (oldest to newest, the default) or Descending (newest to oldest). |
| Template | How each message is written in the text output. The default is {sender_name}: {text}, which gives lines like “User: Hello”. You can use {text}, {sender}, {sender_name} or other message fields. |
Output
The component has three outputs. When you connect one, the other two are hidden:
- Messages (Data): one piece of data per message, with its text, sender and other details.
- Messages (Text): the whole history as a single text, with each message written according to Template.
- Memory: the history as a memory, to connect to a component that accepts one.
Example
A booking assistant works over chat. Before the model answers, Chat Memory retrieves the last 10 messages of the current session (Number of Messages = 10, Session ID = the chat session). The Messages (Text) output is added to the prompt, so the model remembers the customer already gave the date and number of people.
Good practices
- Keep Number of Messages to what the model really needs: a very long history makes answers slower and more expensive.
- Always set the session or conversation if the flow serves several people, so histories don’t get mixed.