Skip to main content
This guide walks you through building a customer support agent with persistent memory powered by HydraDB. Unlike generic chatbots that answer the same way for every customer, this agent knows who it’s talking to - their plan, their history, their preferences, and what already didn’t work - before it types a single word.
Note: All code in this guide is production-ready and uses real HydraDB endpoints. Base URL: https://api.hydradb.com. Get your API key at app.hydradb.com.
Goal: Build a support agent that makes two fast HydraDB calls on every ticket - one to retrieve knowledge base context, one to retrieve customer memory - merges both, and passes the result to an LLM for a personalized response. Full round-trip under 400ms.

Prerequisites

Required knowledge: Python basics, REST APIs, environment variables
Required tools:
  • HydraDB API key
  • Python 3.11 or 3.12 (python --version)
  • OpenAI API key (for generating the final support response)
  • pip install hydradb-sdk openai

What You’ll Build

By the end of this cookbook, you’ll be able to:
  • Ingest help docs and past ticket resolutions into a shared HydraDB knowledge base
  • Store per-customer memory so the agent knows their plan, history, and preferences before responding
  • Make the two-call search pattern - knowledge base + customer memory - on every incoming ticket
  • Generate personalized support responses that reference the customer’s specific context
  • Store every conversation turn back into HydraDB to continuously improve future responses

The Problem with Generic Support Bots

Standard AI support chatbots answer the same way for every customer. Ask about a billing issue and you get the generic billing FAQ. The agent has no idea you’ve asked this three times, that you’re on the Enterprise plan, or that the last agent told you it was a known bug being fixed this sprint. HydraDB fixes this. Every interaction is stored as a memory. Every help doc and past ticket resolution is ingested as knowledge. When a customer opens a new conversation, the agent makes two fast calls to HydraDB:
  1. POST /query - retrieves knowledge base context: help articles, past ticket resolutions, and linked documents relevant to the customer’s message.
  2. POST /query - retrieves the customer’s personal memory: their plan, past issues, inferred preferences, and conversation history.
Both results are merged and passed to the LLM. The result is a support agent that feels like it knows the customer personally. Because it does.

How HydraDB Enables This

Three HydraDB primitives power this use case:
  • Knowledge memories - help docs, FAQs, past ticket resolutions. Uploaded once via client.context.ingest() and continuously available to every agent handling any customer. HydraDB automatically builds a context graph linking related articles and resolutions.
  • User memories - per-customer context stored via POST /context/ingest with the customer’s user_name. Each conversation turn, product feedback signal, and inferred preference is stored here. HydraDB’s infer: true mode automatically extracts implicit preferences from conversation text - “I’d prefer email updates” becomes a stored preference without you parsing it.
  • Two-call search pattern - when a customer opens a ticket, the agent calls POST /query to search the knowledge base and POST /query to retrieve personal memory. Results are merged before the LLM call. Use mode: "thinking" on both calls to enable personalised ranking.

Architecture Overview


Step 1 - Create Database

One database for your support system. Use collections to isolate customer data - each customer gets their own collection, automatically created on their first interaction. This is the B2C pattern from HydraDB’s docs.
SDK required: Install the official Python SDK - pip install hydradb-sdk. The ingestion endpoint (upload_knowledge) requires the SDK; raw requests with json= will return a 422. Note: the import name differs from the package name.
Output:

Step 2 - Ingest Knowledge Base

Upload your help docs, FAQs, and past ticket resolutions into a shared knowledge-base collection. HydraDB builds a context graph connecting related articles automatically - a question about “billing” will surface linked articles about “invoices”, “payment methods”, and “plan upgrades” even if the customer didn’t mention those words.
Batch limit: Max 20 sources per request. Wait 1 second between batches.
Important - database placement: database and collection must appear in two places: as top-level SDK parameters AND inside each item in app_knowledge. The AppKnowledgeModel validates both independently. Omitting either location returns a 400 error.
app_knowledge format: The SDK parameter app_knowledge takes a JSON string - use json.dumps(batch), not a Python list directly.

Help Docs & FAQs

Past Ticket Resolutions

Past resolved tickets are gold - they contain the exact diagnosis path, the solution that worked, and the customer context. Include resolution steps and root cause so HydraDB can build graph links between symptoms and solutions.

Step 3 - Build Per-Customer Memory

Every customer gets their own persistent memory in HydraDB. This is what makes the agent feel personal. The memory contains every conversation turn, every preference signal, every product feedback item - and HydraDB continuously re-ranks which memories are most useful for the current interaction.

Store Conversation Turns

After every message exchange, write both the customer message and agent response to HydraDB. Use infer: false for verbatim storage - you want the exact words so future search can surface the precise prior exchange.

Infer User Preferences

Store inferred preferences separately using infer: true. HydraDB extracts implicit signals from the text - preferred contact method, technical expertise level, frustration signals - and connects them to related context in the graph.
When to call this: After ticket resolution (“customer confirmed this fix works”), when a customer expresses a preference explicitly (“can you just send me a link instead of steps?”), or when your system detects a pattern (third ticket about the same feature). Also call it at account creation time with CRM data - plan type, company size, primary use case.

Step 4 - Handle a Support Request

When a customer opens a ticket, the agent makes two search calls to HydraDB, merges the results, then generates a response. /query searches the knowledge base; /query searches the customer’s personal memory. Both are needed - neither alone returns the full picture.

Search Customer Context

Generate a Personalized Response

Pass the merged context to an LLM. The personal memory chunks surface what the customer’s plan is, what they’ve already tried, and their communication preferences. The knowledge base chunks provide the actual solution. The LLM just needs to write the reply.
Alternative - skip the LLM: Use POST /query with mode: "thinking" and collection: customer_id to have HydraDB generate the answer directly. Faster, but less control over the system prompt and tone.

Step 5 - Escalation & Human Handoff

When the agent can’t resolve an issue, it escalates to a human - but critically, it sends the full HydraDB context with it. The human agent sees everything: the customer’s account history, what the AI already tried, similar past tickets, and the customer’s preferences. No “hi, can you describe your issue again?”

Step 6 - Slack & Email Interface

Expose the support agent on Slack for internal teams and via email webhook for customer-facing support. Both use the same handle_ticket function - HydraDB’s memory layer works identically across channels. A customer who emailed last week and now opens a Slack thread gets the same personalized context because both are stored under their customer_id.

Slack

Email Webhook

Example response (customer on Enterprise plan who asked about a billing issue twice before):

API Reference

All endpoints used in this cookbook. Base URL: https://api.hydradb.com · Header: Authorization: Bearer YOUR_API_KEY

Create Database

Upload Knowledge (via SDK)

Store Customer Memory (Conversation Turn)

Store Customer Preference

Search Knowledge Base

Search Customer Memory


Benchmarks

Tested across 2,400 real support tickets (mix of billing, technical, onboarding, account issues) with and without HydraDB memory. Human raters evaluated response quality and relevance.
The 94% drop in repeated troubleshooting steps is the most direct result of persistent memory. Without HydraDB, a customer who reports the same SSO issue for the third time gets the same “try clearing your browser cache” suggestion. With HydraDB, the agent knows that was already tried - and tried twice - and goes straight to the next level of diagnosis.
Benchmark methodology: Figures are based on internal HydraDB testing. See research.hydradb.com/hydradb.pdf for the full paper. Results will vary by corpus size, content quality, and query distribution.

File Structure

Requirements


Next Steps

  1. Run setup.py to create your database and verify the connection.
  2. Run the ingestion scripts with your real help docs and past tickets.
  3. Seed a few customer memories from your CRM at account creation time.
  4. Wire handle_ticket into your existing support channel (email, Slack, or web chat).
The agent improves automatically - every conversation stored via context.ingest(type="memory") makes the next response for that customer more personalized. There is no retraining step. HydraDB re-ranks memories continuously as new interactions come in.