Developers

Voice+

Getting started

The @nlxai/voice-plus-core package is used to implement Voice+ conversational applications. By installing the SDK and creating a client instance specific to a journey, you can send steps in response to any user interaction, triggering voice feedback on a second channel (e.g. voice).

Setup

On a webpage:

1<script defer src="https://unpkg.com/@nlxai/voice-plus-core/lib/index.umd.js"></script> 2<script> 3 const contentLoaded = () => { 4 if (document.readyState === "loading") { 5 return new Promise((resolve) => { 6 window.addEventListener("DOMContentLoaded", () => { 7 resolve(); 8 }); 9 }); 10 } else { 11 return Promise.resolve(); 12 } 13 }; 14 15 contentLoaded().then(() => { 16 const client = nlxai.voicePlusCore.create({ 17 // hard-coded params 18 apiKey: "REPLACE_WITH_API_KEY", 19 workspaceId: "REPLACE_WITH_WORKSPACE_ID", 20 scriptId: "REPLACE_WITH_SCRIPT_ID", 21 // dynamic params 22 conversationId: "REPLACE_WITH_CONVERSATION_ID", 23 languageCode: "REPLACE_WITH_LANGUAGE_CODE", 24 }); 25 26 client.sendStep("REPLACE_WITH_STEP_ID"); 27 }); 28</script>

In a bundled JavaScript application or Node.js:

1import * as voicePlusCore from "@nlxai/voice-plus-core"; 2 3const client = voicePlusCore.create({ 4 // hard-coded params 5 apiKey: "REPLACE_WITH_API_KEY", 6 workspaceId: "REPLACE_WITH_WORKSPACE_ID", 7 scriptId: "REPLACE_WITH_SCRIPT_ID", 8 // dynamic params 9 conversationId: "REPLACE_WITH_CONVERSATION_ID", 10 languageCode: "REPLACE_WITH_LANGUAGE_CODE", 11}); 12 13client.sendStep("REPLACE_WITH_STEP_ID");