dialnexa
v1.0.3
Published
JavaScript SDK for dialnexa APIs
Readme
dialnexa JavaScript SDK (TypeScript)
TypeScript-based JavaScript SDK for dialnexa APIs. It provides small, fetch-based helpers (via a single client factory) for:
- Languages
- LLMs
- Calls
- Batch Calls (file upload)
- Agents v2
- Voices
The SDK targets ESM (Node 18+). Source lives in src, build output in dist/.
Requirements
- Node.js 18+
- npm
Getting Started
- Install deps and build
npm install
npm run build- Set environment variables
You can use a .env file or set them in your shell. Required:
DIALNEXA_API_KEY
PowerShell (Windows):
$env:DIALNEXA_API_KEY = '<your_api_key>'bash/zsh:
export DIALNEXA_API_KEY='<your_api_key>'Importing
After npm run build, import the client factory from the package root and use the namespaced helpers.
import { createClient } from 'dialnexa';
const dialnexa = createClient({
apiKey: process.env.DIALNEXA_API_KEY,
});API Overview
Below are minimal examples using the client. Configure apiKey, optional baseUrl, and timeoutMs when creating the client.
Languages
const languages = await dialnexa.languages.list();
const en = await dialnexa.languages.get('en-US');LLMs
const llms = await dialnexa.llms.list();
const DEFAULT_LLM_ID = 'llm_123';
const one = await dialnexa.llms.get(DEFAULT_LLM_ID);Calls
// List calls with pagination
const calls = await dialnexa.calls.list({ page: 1, limit: 30 });
const PHONE = '+15555551234';
const AGENT_ID = 'agent_123';
const AGENT_VERSION_NUMBER = 1;
const created = await dialnexa.calls.create({
phone_number: PHONE,
agent_id: AGENT_ID,
agent_version_number: AGENT_VERSION_NUMBER,
metadata: { source: 'sdk' },
});
const call = await dialnexa.calls.get(created.call_id);Batch Calls
import fs from 'node:fs';
const stream = fs.createReadStream('./leads.csv');
const TITLE = 'My Campaign';
const AGENT_ID = 'agent_123';
const AGENT_VERSION_NUMBER = 1;
const resp = await dialnexa.batchCalls.create({
file: stream,
filename: 'leads.csv',
title: TITLE,
agentId: AGENT_ID,
agentVersionNumber: AGENT_VERSION_NUMBER,
});Agents
const created = await dialnexa.agents.create({
title: 'Customer Support Agent',
prompts: {
prompt_text: 'Hello!',
welcome_message: 'Welcome! I\'m here to help.',
conversation_start_type: 'user',
},
});
const listed = await dialnexa.agents.list();
const one = await dialnexa.agents.get(created.data?.id ?? created.data?.agent_id);
const updated = await dialnexa.agents.update(created.data?.id ?? created.data?.agent_id, {
version_number: 1,
title: 'Updated Title',
});Voices
const list = await dialnexa.voices.list({ provider_name: 'elevenlabs', limit: 10 });
const VOICE_ID = 'voice_abc';
const voice = await dialnexa.voices.get(VOICE_ID);Running Examples
All examples are under examples/ (ESM). Build the SDK first (npm run build).
node examples/languages.mjs [voiceModelId] [languageId]
node examples/llms.mjs [page] [limit] [sortBy] [sortOrder] [id]
node examples/calls.mjs [page] [limit] [phoneToCreateOrNull]
node examples/batch-calls.mjs <file_path>
node examples/agents.mjs
node examples/voices.mjs [voiceId]Project Layout
src/— TypeScript sourcedist/— compiled JS/typings (generated bynpm run build)examples/— runnable example scripts
Publishing
dist/is ignored by Git but included in npm via thefilesfield.prepublishOnlyrunsnpm run buildautomatically before publishing.
Troubleshooting
- Ensure Node 18+ and ESM are used (package
type: module). - For file uploads in Node, pass a
ReadStream,Buffer,Uint8Array, orBlob.
License
MIT
