Skip to main content
Version: 3.6.0

API Reference

OptaveJavaScriptSDK(options)​

Creates a new instance of the OptaveJavaScriptSDK.

Parameters​

  • options (Object): Configuration options.
    • websocketUrl (string): The WebSocket URL.
    • authenticationUrl (string, optional): The authentication URL.
    • clientId (string, optional): The client ID for authentication.
    • clientSecret (string, optional): The client secret for authentication.

authenticate()​

Authenticates the client using the provided credentials and retrieves an access token.

  • Returns: Promise<string>: The access token.

openConnection(bearerToken)​

Establishes a WebSocket connection using the provided bearer token.

Parameters​

  • bearerToken (string): The authentication token.

closeConnection()​

Closes the active WebSocket connection.

send(requestType, action, params, version)​

Sends a message through the WebSocket connection.

  • Parameters:
    • requestType (string): The type of the request.
    • action (string): The specific action to perform.
    • params (Object): The parameters for the request.
    • version (number, optional): The payload version (default is 2).

Predefined Methods​

These methods are shortcuts for sending specific types of messages.

  • customerInteraction(params): Sends a customerinteraction message.
  • assistant(params): Sends an assistant message. Available from SDK version 3.6.0.
  • elevate(params): Sends an elevate message.
  • adjust(params): Sends an adjust message.
  • summarize(params): Sends a summarize message.
  • translate(params): Sends a translate message.
  • recommend(params): Sends a recommend message.
  • insights(params): Sends an insights message.

EventEmitter Methods​

Since OptaveJavaScriptSDK extends EventEmitter, you can use all standard EventEmitter methods such as on, once, emit, etc.