Sales AI
Build AI sales assistants that leverage CRM data and customer history.
The Problem
Sales AI without memory:
- Gives generic, scripted responses
- Doesn't know customer history
- Misses personalization opportunities
- Can't reference past conversations
The Solution
Memory-enabled sales AI that:
- Knows each customer's history
- References past purchases and interactions
- Personalizes outreach and follow-ups
- Learns what works for each account
Implementation
Storing Customer Data
import requests
MEMORY_API = "https://api.memory.tensorheart.com/v1"
API_KEY = "mem_live_..."
def sync_crm_data(account_id: str, data: dict):
"""Sync CRM data to memory."""
memories = [
f"Company: {data['company']}",
f"Industry: {data['industry']}",
f"Contact: {data['contact_name']}, {data['title']}",
f"Deal size: ${data['deal_value']:,}",
f"Stage: {data['stage']}"
]
for memory in memories:
requests.post(
f"{MEMORY_API}/memories",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"text": memory,
"space_id": f"account_{account_id}",
"metadata": {"source": "crm"}
}
)
Personalized Outreach
from openai import OpenAI
openai = OpenAI()
def generate_outreach(account_id: str, purpose: str) -> str:
"""Generate personalized sales outreach."""
# Get account context
response = requests.post(
f"{MEMORY_API}/query",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"context": purpose,
"space_id": f"account_{account_id}",
"max_memories": 10
}
)
memories = [m["text"] for m in response.json().get("data", {}).get("memories", [])]
context = "\n".join(f"- {m}" for m in memories)
response = openai.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": f"Account context:\n{context}\n\nWrite personalized sales copy."},
{"role": "user", "content": purpose}
]
)
return response.choices[0].message.content
# Example
email = generate_outreach("acme_123", "Follow up on demo request")
Example
Input: Draft follow-up email for Acme Corp demo
Memory retrieves:
- "Company: Acme Corp, Series B startup"
- "Contact: Sarah, VP of Engineering"
- "Interested in API monitoring features"
- "Previous call: Discussed SOC2 compliance needs"
Output:
"Hi Sarah,
Great connecting last week about API monitoring. I wanted
to follow up on the SOC2 compliance question you raised..."
Next Steps
- Building Agents — Memory patterns for AI
- API Reference — Full documentation