Developers

Multimodal

Usage

The Multimodal client is initiated with dynamic params and hard-coded parameters.

Hard-Coded params

Hard-coded params should be simply copied and pasted from the NLX console. They are

  • workspaceId for your workspace
  • journeyId where the step(s) exists
  • apiKey every journey has a correlated api key

Dynamic Params

Dynamic params should be set based on the user's context. They are

  • conversationId should be passed to your multimodal from the intent (via, for instance, a URL param)
  • languageCode should be set based on the user's language. If you don't support internationalization you can hard-code this to the language you support.

Examples

Here are some examples for different usages:


A simple HTML example

The conversationID and the languageCode must be set dynamically.

In this example,

  • the conversationId comes from a URL search param (CID, e.g. http://example.com?cid=123).
  • the languageCode comes from the browser's language settings. (navigator.language)

Note: When using this approach, pass conversationId in the URL as a search param when navigating to new pages. For an alternative, see the next example.

1<script defer src="https://unpkg.com/@nlxai/multimodal/lib/index.umd.js"></script> 2<script> 3 const client = nlxai.multimodal.create({ 4 // hard-coded params 5 apiKey: "REPLACE_WITH_API_KEY", 6 workspaceId: "REPLACE_WITH_WORKSPACE_ID", 7 journeyId: "REPLACE_WITH_JOURNEY_ID", 8 // dynamic params 9 conversationId: new URLSearchParams(window.location.search).get("cid"), 10 languageCode: navigator.language, 11 }); 12 13 client.sendStep("REPLACE_WITH_STEP_ID"); 14</script>