Chat with Memory Conversation
The main goal of this flow is for the AI agent to maintain a coherent dialogue. To achieve this, the system combines the current message with the conversation memory, allowing the response to be based on the full context.
graph TD
%%{init: {'theme': 'mc','layout': 'elk'}}%%
Prompt-r16pz[<div><img src="/_astro/square-terminal.BMOXc-nZ.svg" style="height: 20px !important;width: 20px !important"/></div>Prompt]
style Prompt-r16pz stroke:#a170ff
ChatInput-tj4g4[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Input]
style ChatInput-tj4g4 stroke:#a170ff
ChatOutput-17n0s[<div><img src="/_astro/messages-square.BaSDmT6g.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Output]
style ChatOutput-17n0s stroke:#a170ff
Memory-43b97[<div><img src="/_astro/message-square-more.wNo_B7mh.svg" style="height: 20px !important;width: 20px !important"/></div>Chat Memory]
style Memory-43b97 stroke:#a170ff
GoogleGenerativeAIModel-6dquc[Google Generative AI]
style GoogleGenerativeAIModel-6dquc stroke:#a170ff
ChatInput-tj4g4 -.- Prompt-r16pz
linkStyle 0 stroke:#a170ff
Memory-43b97 -.- Prompt-r16pz
linkStyle 1 stroke:#a170ff
Prompt-r16pz -.- GoogleGenerativeAIModel-6dquc
linkStyle 2 stroke:#a170ff
GoogleGenerativeAIModel-6dquc -.- ChatOutput-17n0s
linkStyle 3 stroke:#a170ff
đź§© Overview
This workflow powers a conversational agent that remembers prior exchanges and generates responses using Google Generative AI.
When a user submits a message, the system pulls the conversation history, composes a context‑rich prompt, feeds it to the language model, and returns the AI’s reply.
The result is a coherent, context‑aware dialogue that feels natural and keeps track of the entire chat.
⚙️ Main Features
- Captures user input through a chat interface and tags it with the conversation context.
- Retrieves the latest messages from an external memory store or local history.
- Builds a structured prompt that merges user text and retrieved context.
- Sends the prompt to Google Generative AI to generate a natural‑language response.
- Displays the AI’s reply back to the user within the same chat session.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Chat Input | Accepts the user’s message and conversation metadata. | User text, conversation ID, optional file attachments, sender details. | Message object containing the user’s input. |
| Chat Memory | Retrieves recent messages to provide context for the prompt. | Conversation ID, memory settings (number of messages, order, sender filters). | Text representation of the conversation history. |
| Prompt | Constructs a combined prompt that includes context and the current user message. | Context text, user message text. | Prompt message ready for the language model. |
| Google Generative AI Model | Generates the AI’s reply based on the prompt. | Prompt text, system message (optional), temperature and other generation parameters. | Generated text response. |
| Chat Output | Sends the AI’s response back to the user in the chat interface. | Generated text, conversation ID, sender information. | Message object containing the AI reply. |
đź§ Notes
- The flow assumes a valid Google API key and credentials are configured for the AI model.
- System messages can be supplied to guide the model’s behavior; if omitted, the default model instructions are used.
- Streaming is enabled by default, allowing partial responses to appear as they are generated.
- The memory component limits the number of retrieved messages (default 20) and can filter by sender or order.
- Output text is formatted according to the data template; if left empty, the model’s raw text is used.
- Label components are decorative and do not participate in data processing; they merely describe each stage for documentation purposes.