Custom Response

Implement application-specific voice commands by attaching a knowledge base to your Voice+ node in the flow builder. This allows you to define custom actions that can be triggered by voice commands.

Enriching the Knowledge Base

To enrich the article Q&A Knowledge Base Responses with custom voice+ commands, you will need to add MetaData to each of the responses.

There are built in metadata keys that will trigger the input or navigation classifications, but you can also define your own custom actions.

Key
Classification
Action
Description

nlx:destination

navigation

page_custom

Navigate to a specific page or section

nlx:action

custom

Custom action name

Send custom actions to the frontend.

nlx:actionPayload

custom

Custom action data

Optional value only taken into account if nlx:action key is present. Sent as payload key to the frontend along with command type custom and action = nlx:action key value

Example Payloads

Suppose I want to create a custom command that sends users to the contact page when they'd like to get in touch about animal policy along with extra information.

I create a new Article in the Knowledge Base attached to the Voice+ Node with the following content:

  • Question: How do I get in touch about animal policy?

  • Answer: You can contact us about animal policy by visiting our Contact Page.

metadata key
value

nlx:destination

contact

nlx:action

animalPolicy

nlx:actionPayload

{}

nlx:actionPayload.dog

true

nlx:actionPayload.cat

true

I will receive TWO payloads from NLX when this article is triggered, one for the navigation command and one for the custom command.

Example Navigation Command:

{
  "classification": "navigation",
  "action": "page_custom",
  "destination": "contact"
}

Example Custom Command:

{
  "classification": "custom",
  "action": "animalPolicy",
  "payload": {
    "dog": true,
    "cat": true
  }
}

Sample Knowledge Base Response Handler

function handleCustomCommand(action, payload) {
  // Example: Voice-enabled product search
  if (action === "animalPolicy") {
    setDogPolicy(payload.dog);
    setCatPolicy(payload.cat);
  }
}

const touchpointOptions = {
  config: {
    applicationUrl: "YOUR_APPLICATION_URL",
    headers: {
      "nlx-api-key": "YOUR_API_KEY",
    },
    languageCode: "en-US",
  },
  input: "voiceMini", // Enables voice input with bidirectional support
  bidirectional: {
    custom: handleCustomCommand,
  },
};

Last updated