Dashboard →

JavaScript SDK

Give your AI agent persistent memory. Simple JavaScript SDK for natural language ingestion and querying.

Installation

npm install antonlytics

Or with Yarn:

yarn add antonlytics

Quick Start

import { Agent } from 'antonlytics';

// Initialize agent
const agent = new Agent({
  apiKey: 'your-api-key',
  projectId: 'your-project-id'
});

// Ingest data - agent learns
await agent.ingest(`
  Had a call with Sarah Johnson from TechCorp today.
  She's interested in our Enterprise plan for 50 users.
  Follow up next Tuesday to discuss pricing.
`);

// Chat with agent - agent remembers
const response = await agent.chat("Who should I follow up with?");
console.log(response.response);
// => "You should follow up with Sarah Johnson from TechCorp. 
//     She expressed strong interest in the Enterprise plan..."

// Access relevant entities
response.relevant_entities.forEach(entity => {
  console.log(`${entity.name} - ${entity.type}`);
});

Two Usage Options

Option 1: Use Our Model

We handle everything. System prompt + memory + AI response.

// Full-service
const response = await agent.chat(
  "Who to follow up?"
);

console.log(response.response);

Option 2: Use Your Model

Get memory context. Feed to your own model.

// Just memory
const memory = await agent.getMemory();

// Your model
const response = await yourModel.chat({
  context: memory,
  message: "Who to follow up?"
});

Core Methods

agent.ingest(text)

Ingest natural language text. Automatically extracts entities and relationships.

// Ingest meeting notes
const result = await agent.ingest(`
  Meeting with Alice Johnson from DataCorp.
  She's the CTO and wants Pro plan for 20 engineers.
  Budget approved for Q2. Integrate with Slack required.
`);

console.log(result.created);
// => {entities: 3, relationships: 2}

console.log(result.extracted.entities);
// => [
//   {name: "Alice Johnson", type: "Person"},
//   {name: "DataCorp", type: "Company"},
//   ...
// ]

agent.chat(message)

Chat with your agent. Uses system prompt + full memory context.

// Ask questions
const response = await agent.chat("What deals are in progress?");
console.log(response.response);

// Access entities mentioned
response.relevant_entities.forEach(entity => {
  console.log(entity.name, entity.properties);
});

agent.getMemory(query?)

Get structured memory for your own model. Returns entities and relationships.

// Get all memory
const memory = await agent.getMemory();

// Get filtered memory
const memory = await agent.getMemory("Enterprise deals");

// Use with your model
import OpenAI from 'openai';
const openai = new OpenAI();

const response = await openai.chat.completions.create({
  model: "gpt-4",
  messages: [
    {role: "system", content: "You are a sales assistant"},
    {role: "system", content: `Memory: ${JSON.stringify(memory)}`},
    {role: "user", content: "Who to follow up?"}
  ]
});

console.log(response.choices[0].message.content);

agent.setSystemPrompt(prompt)

Configure agent behavior and personality.

await agent.setSystemPrompt(`
  You are a helpful sales assistant.
  Your role is to:
  - Track leads and their interests
  - Identify follow-up opportunities  
  - Provide context on past conversations
  - Suggest next steps for deals
  
  Be professional, concise, and action-oriented.
`);

Complete Example

import { Agent } from 'antonlytics';

// Initialize
const agent = new Agent({
  apiKey: 'your-api-key',
  projectId: 'your-project-id'
});

// Set behavior
await agent.setSystemPrompt(`
  You are a sales assistant.
  Focus on follow-ups and next steps.
`);

// Ingest conversation
await agent.ingest(`
  Call with Mike Rodriguez from StartupXYZ.
  He's the founder. Looking at our API for their mobile app.
  Has 100K users. Wants custom pricing.
  Send proposal by Friday.
`);

await agent.ingest(`
  Email from Sarah Chen at BigCorp.
  VP of Engineering. Interested in Enterprise.
  Team of 200 developers. Budget discussion next week.
`);

// Query memory
const response = await agent.chat("What are my top priorities this week?");
console.log(response.response);
// => "Your top priorities:
//     1. Send proposal to Mike at StartupXYZ by Friday
//     2. Prepare for budget discussion with Sarah at BigCorp next week"

// Get all contacts
const contacts = await agent.chat("List all people I've talked to");
contacts.relevant_entities
  .filter(e => e.type === "Person")
  .forEach(e => console.log(`- ${e.name}`));
// => - Mike Rodriguez
//    - Sarah Chen

Using Your Own Model

You can use Antonlytics just for memory and bring your own model:

import { Agent } from 'antonlytics';
import { YourAgent } from './your-agent';

// Antonlytics for memory
const memoryAgent = new Agent({
  apiKey: '...',
  projectId: '...'
});

// Ingest data
await memoryAgent.ingest("Call with Sarah from TechCorp...");

// Get memory context
const memory = await memoryAgent.getMemory();

// Your agent with memory
const yourAgent = new YourAgent();
const response = await yourAgent.query({
  context: memory,
  prompt: "Who should I follow up with?"
});

console.log(response);
// Your model has access to structured memory!

Node.js vs Browser

Node.js

// CommonJS
const { Agent } = require('antonlytics');

// ES Modules
import { Agent } from 'antonlytics';

const agent = new Agent({
  apiKey: process.env.ANTONLYTICS_API_KEY,
  projectId: process.env.ANTONLYTICS_PROJECT_ID
});

Browser

// ES Modules
import { Agent } from 'antonlytics';

const agent = new Agent({
  apiKey: 'your-api-key',
  projectId: 'your-project-id'
});

// Works in React, Vue, etc.

API Reference

MethodDescription
ingest(text)Extract and store entities/relationships
chat(message)Chat with agent (uses our model)
getMemory(query?)Get memory context for your model
setSystemPrompt(prompt)Configure agent behavior
getSystemPrompt()Get current system prompt

Get Your API Key

Get your API key from the dashboard to start using the SDK.

Go to Dashboard