Skip to content

Latest commit

 

History

History
82 lines (58 loc) · 2.6 KB

File metadata and controls

82 lines (58 loc) · 2.6 KB

Internal knowledge assistant

An employee-facing handbook assistant that also talks to teammates in realtime. This is the example to read for realtime messaging: WebSocket transport, send, inbound onMessage, and fetchChatHistory.

Two clients, two transports

The example runs the documented production pattern — one DNotifier instance per job:

Client Transport Job
realtime ws Teammate messages: send, inbound onMessage, fetchChatHistory
ai http Request/response work: sendAI, addDocument, search, listDocuments

Request/response calls are simpler over HTTP, and keeping them off the socket leaves it free for inbound messages. In Node the WebSocket transport has no built-in implementation, so the ws package is passed as WebSocketImpl; Python and Dart use the WebSocket client bundled with their SDK.

Each CLI reads input without blocking its event loop (a worker thread in Python, an async stdin stream in Dart), so a message from a teammate prints the moment it arrives — even mid-prompt.

DNotifier building blocks

API Used for
send Send a message to a teammate over the socket
onMessage Print inbound teammate messages as they arrive
fetchChatHistory Replay the persisted 1:1 conversation
sendAI with useKnowledgeBase Answer handbook questions
addDocument / listDocuments / search Manage and inspect the handbook index

Seeing both sides

Run two terminals with the user ids swapped, then /dm between them:

# terminal 1
DNOTIFIER_USER_ID=alex TEAMMATE_ID=jordan npm start

# terminal 2
DNOTIFIER_USER_ID=jordan TEAMMATE_ID=alex SEED_KB=false npm start

/share <question> is the combined path: it asks the handbook over HTTP, then relays the answer to your teammate over the socket.

Run examples

Create an app at app.dnotifier.com, copy .env.example.env, set credentials.

TypeScript (Node)

cd typescript
cp .env.example .env
npm install
npm start

Python

cd python
cp .env.example .env
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python main.py

Dart

cd dart
cp .env.example .env
dart pub get
dart run bin/main.dart

Then try: How many PTO days do I get?, /dm standup in 5, or /history.

Languages

Language Path Run
TypeScript typescript/ npm start
Python python/ python main.py
Dart dart/ dart run bin/main.dart