Node SDK

npm install @glytos/node

Setup

import { Glytos } from '@glytos/node';

const glytos = new Glytos({ apiKey: process.env.GLYTOS_API_KEY! });

To act in a specific environment, name it - dev, staging, prod, or an environment uuid. It defaults to Development.

const prod = new Glytos({ apiKey: process.env.GLYTOS_API_KEY!, environment: 'prod' });

Text conversations

A thread holds a conversation; a run is one turn on it. The reply is in the result - there is no run to poll. See Chat.

const thread = await glytos.threads.create({ agent: agentUuid });
const run = await glytos.threads.runs.create(thread, 'What are your opening hours?');

// Or stream it as it is written
for await (const event of glytos.threads.runs.stream(thread, 'Summarise the policy')) {
  if (event.type === 'token') process.stdout.write(event.delta);
}

agents is an alias of workflows: the product calls them agents, the API path is /workflows. Either works.

Resources

The client exposes the API by resource:

await glytos.workflows.list();
await glytos.workflows.retrieve(uuid);
await glytos.workflows.create({ name: 'Receptionist', mode: 'prompt' });
await glytos.workflows.publish(uuid);

await glytos.calls.create({ transport: 'phone', workflow_uuid: uuid, to_number: '+1...' });
await glytos.calls.list();

await glytos.workflows.session(workflowUuid, sessionUuid);

The client covers agents (alias workflows), threads, folders, imports, chat, calls, phoneNumbers, sipTrunks, campaigns, dnc, sessions, webhooks, tools, knowledgeBase, vectorStores, integrations, automations, testSuites, analytics, billing, environments, providers, apiKeys and organizations.

Anything not wrapped

The SDK is thin on purpose. Anything it does not wrap is still reachable, with auth and error handling applied:

await glytos.request('GET', '/audit');

Verifying webhooks

import { verifyWebhook } from '@glytos/node';

// `rawBody` must be the untouched request body - parsing and re-serialising it
// changes the bytes and the signature will not match.
const ok = verifyWebhook(rawBody, request.headers['x-glytos-signature'], secret);

It is also on the client as glytos.webhooks.verify(...). See Webhooks.

Node SDK · Glytos Docs