Skip to Content

Getting Started

TypeScript quickstart

Install the TypeScript SDK, store a memory, recall it, and query an engine from Node.js in a few minutes.

In a few minutes you'll install docklee, write a memory with Dock, read it back with Lynk, and ask an engine a question, all from Node.js. The same code runs as plain JavaScript if you drop the type imports.

Prerequisites

  • Node.js 18+.
  • An API key with the Both capability. See API keys.
  • A memory space ID from DUM, and an engine ID from Knowledge Engines, in the Docklee dashboard.

Store and recall from TypeScript

Install the package

npm install docklee

Set your environment

export DOCKLEE_API_KEY="your-api-key"
export DOCKLEE_MEMORY_SPACE_ID="your-memory-space-id"
export DOCKLEE_ENGINE_ID="your-engine-id"

Dock and Lynk read these on creation, so your code never holds the key.

Write a memory

capture returns at once. flush sends the buffer and resolves with the result:

import { Dock } from 'docklee';

const dock = new Dock();
dock.capture('Maya prefers email over phone calls.', { type: 'preference', endUser: 'user_8f2c' });
const result = await dock.flush();
console.log(result?.accepted, result?.rejected);
1 0

Recall it

import { Lynk } from 'docklee';

const lynk = new Lynk();
const records = await lynk.recall('How does Maya like to be contacted?', { endUser: 'user_8f2c' });
for (const record of records) {
  console.log(record.confidence, record.content);
}
0.87 Maya prefers email over phone calls.

Ask an engine

import type { KnowledgeResult } from 'docklee';

const result = (await lynk.query('What is the refund window?')) as KnowledgeResult;
console.log(result.answer);
Customers can request a refund within 30 days of purchase.

Let your process exit

Dock sends its buffer on a timer while it's open. Close it when you're done, so the timer stops and the last events are sent:

await dock.close();

Call the SDK from your server. An API key in browser code can be read by anyone who opens the page.

Next steps

You've used every part of the SDK once. Start with configuration, since every app sets it up a little differently.

On this page