DEV Community

Karanam Lakshmi Sai Amogha
Karanam Lakshmi Sai Amogha

Posted on AI-assisted

Two API Calls Gave My Sales Agent a Memory

The most expensive moment in a sales call is when the rep asks a question the client already answered three weeks ago.

I built a small AI Sales Agent to solve that problem. It stores previous client conversations and recalls the relevant information before the next call to generate a more useful pre-call briefing.

What it does

The Deal Intelligence Agent is a FastAPI application that connects a simple browser interface with Hindsight memory and a Groq LLM.

The main flow is:

  • A salesperson enters the client name and call transcript.
  • The transcript is stored using Hindsight.
  • Before the next call, the agent recalls relevant information about that client.
  • The recalled memories are sent to the LLM.
  • The LLM generates a tactical pre-call briefing.

The main technologies used are Python, FastAPI, Hindsight and Groq.

Deal Intelligence Agent Architecture

Architecture of the Deal Intelligence Agent: Browser UI → FastAPI Backend → Hindsight memory and Groq LLM.

The memory layer

The Hindsight client is configured directly in the FastAPI application:

hindsight_client = Hindsight(
    base_url="https://api.hindsight.vectorize.io",
    api_key=HINDSIGHT_API_KEY
)

BANK_ID = "deal-intelligence-bank"
Enter fullscreen mode Exit fullscreen mode


`

The API key is loaded from an environment variable, while the bank ID identifies the memory bank used by the application.

Hindsight client setup

The Hindsight client setup and memory bank configuration in main.py.

Storing a conversation

When a sales call is completed, the transcript is sent to the /process-call endpoint.

`python
@app.post("/process-call")
def process_call(data: CallInput):
content_text = f"Client: {data.client_name}. Call Details: {data.transcript}"

hindsight_client.retain(
    bank_id=BANK_ID,
    content=content_text
)

return {
    "status": "success",
    "message": "Call stored successfully in Hindsight memory!"
}
Enter fullscreen mode Exit fullscreen mode

`

The original conversation is stored instead of creating a separate extraction schema. This keeps the transcript as the source of truth.

Recalling information before a call

When the salesperson requests a briefing, the application creates a query based on the information that matters for the client:

python
query_text = f"Objections, preferences, and history for {client_name}"

memories = hindsight_client.recall(
bank_id=BANK_ID,
query=query_text
)

The important part is that the agent is not simply looking up a fixed database record. It is asking memory for relevant context about the client.

The recalled information is then provided to the LLM:

python
prompt = f"""
You are an expert sales strategist.

Based on the following historical memories recalled from Hindsight:

{memory_context}

Generate a precise, tactical pre-call briefing for {client_name},
highlighting past objections and suggested strategies.
"""

main.py

The FastAPI application, environment configuration, Hindsight client and memory bank in main.py.

The complete flow

The complete process is:

  1. The salesperson enters a client name and transcript.
  2. FastAPI receives the request.
  3. Hindsight retain() stores the conversation.
  4. Before the next call, the application creates a recall query.
  5. Hindsight recall() retrieves relevant memories.
  6. The memories are added to the LLM prompt.
  7. Groq generates the pre-call briefing.

The central idea is simple:

Retain the conversation → Recall the relevant history → Generate a client-specific briefing.

What I learned

The biggest lesson from this project was that an AI agent becomes much more useful when it can access relevant context from previous interactions.

Instead of generating a generic sales response every time, the agent can use information from earlier conversations to make the briefing specific to the client.

The memory layer also keeps the application architecture simple. Hindsight handles storing and recalling the information while the application focuses on the sales workflow and the LLM handles generation.

There are still improvements I would make for a production version, including stronger authentication, better separation between different client accounts, structured handling of recalled memories and more robust error handling.

Final thoughts

The Deal Intelligence Agent started with a simple idea: a sales agent should not have to forget everything after every conversation.

By combining FastAPI, Hindsight memory and an LLM, the application can retain previous conversations, recall relevant information and use that context to generate a more useful pre-call briefing.

The source code is available in the Deal Intelligence Agent repository.

You can learn more about Hindsight in the Hindsight documentation and Hindsight GitHub repository.

`

Available next action: :contentReference[oaicite:0]{index=0}
`

Top comments (0)