SDK

The functionality of this SDK will soon move to the Touchpoint SDK.

The Voice+ Core SDK (@nlxai/voice-plus-core) is a lightweight JavaScript library designed to simplify the integration of Voice+ multimodal features into your web applications.

It handles authentication headers, session management, and API calls to the Voice+ Track API automatically, allowing you to focus on tracking journey steps and synchronizing state.

Installation

Install the package via npm or yarn:

npm install @nlxai/voice-plus-core
# or
yarn add @nlxai/voice-plus-core

Initialization

To start tracking a journey, import the create function and initialize a client. You will need the credentials found in your Voice+ journey configuration.

import { create } from "@nlxai/voice-plus-core";

// Initialize the client
const client = create({
  apiKey: "YOUR_VOICE_PLUS_API_KEY",    // Specific Voice+ Key (x-api-key)
  workspaceId: "YOUR_WORKSPACE_ID",     // Your Workspace ID (x-nlx-id)
  scriptId: "YOUR_SCRIPT_ID",           // The UUID of the journey/script
  conversationId: "XXXXXXXXX",          // Conversation ID for the active voice session
  languageCode: "en-US"                 // Language code (e.g., en-US)
});

Tip: The conversationId is typically passed to your web application via a URL parameter (e.g., sent via SMS during the call) or through a push notification.

Tracking Steps

Use the sendStep method to notify the Voice+ application that a user has reached a specific point in the journey or performed an action.

Basic Usage

// distinct step UUID defined in your Voice+ script
const STEP_ID = "550e8400-e29b-41d4-a716-446655440000";

try {
  await client.sendStep(STEP_ID);
  console.log("Step tracked successfully");
} catch (error) {
  console.error("Failed to track step", error);
}

Sending Context

You can pass an optional context object to send data back to the voice bot (e.g., form selections, user choices).

const context = {
  selectedSeat: "4A",
  mealPreference: "vegetarian"
};

await client.sendStep(STEP_ID, context);

With Trigger Description

You can also provide a description of what triggered the step for analytics debugging.

await client.sendStep({
  stepId: STEP_ID,
  stepTriggerDescription: "User clicked the 'Confirm Seat' button"
});

API Reference

create(config)

Creates a new Voice+ client instance.

Parameter

Type

Description

config.apiKey

String

Required. The Voice+ API Key.

config.workspaceId

String

Required. The NLX Workspace ID.

config.scriptId

UUID

Required. The Journey/Script ID.

config.conversationId

String

Required. The active session ID.

config.languageCode

String

Required. IETF language tag (e.g., en-US).

client.sendStep(stepId, [context])

Parameter

Type

Description

stepId

UUID

Required. The ID of the step to track.

context

Object

(Optional) JSON object containing state data.

Last updated