1. Home
  2. Others
  3. Knowlarity Integration WebSocket
  • User Guide
  • Developer Docs
Frequently visited sections What is verloop?, FAQ Overview?

Knowlarity Integration WebSocket

Websocket URL:

wss://<client_id>.<base_domain>/vaani/knowlarity/setup-call-streams

base_domain is

  • verloop.io(GCP prod)
  • mena.verloop.io (MENA prod)

Example: wss://testing.verloop.io/v2/login/vaani/knowlarity/setup-call-streams

Below is the CURL to update the websocket URL:

curl –location –request POST ‘https://livestreamstaging1.knowlarity.com/knowlarity/update_wss_url’ \

–header ‘Content-Type: application/json’ \

–header ‘Authorization: {API Token}’ \

–header ‘x-api-key: {API Key}’ \

--data-raw '{
    "data": {
        "number": "{phone number}",
        "wss_url": "{websocket url}"
    }
}'

After Configuration the WebSocket URL, you’re all set. You can begin to continuously listen to the user’s audio on the socket.

Inbound: Audio streaming on WebSocket:

The first message that we receive over a WebSocket will be of this type

{
  "uuid": "aosi-adfad-23-ad", // unique identifier per call
  "sample_rate": 16000,
  "from": "<user_phone>",
  "to": "<bot_phone>",
  "campaign": "", // will hold some value only in case of outbounds
  "metadata": {
    "welcome_message": "Welcome to knowlarity",
    "event": "websocket:connected",
    "call_type": "inbound"
  }
}

This message represents the socket is ready to receive the data for a particular incoming call.

Note: Audio is streamed in linear 16 format (16-bit PCM encoding)

Outbound: Audio Streaming on Web Socket:

First message that we receive over a websocket will be of this type

{
  "uuid": "aosi-adfad-23-ad", // unique identifier per call
  "sample_rate": 16000,
  "from": "<user_phone>",
  "to": "<bot_phone>",
  "campaign": "<knowlarity_campaign_id>",
  "metadata": {
    "welcome_message": "Welcome to knowlarity",
    "event": "websocket:connected",
    "call_type": "outbound"
  }
}

Note: <knowlarity_campaign_id> is knowlarity’s campaign ID. Not to be confused with our campaign ID which is different. 

Data sent from us to Knowlarity

Audio data: Raw audio (bot audio) should be base64 encoded and sent as JSON.

{
  "type": "playAudio",
  "data": {
    "audioContentType": "wave",
    "audioContent": "<base64 encoded raw audio>"
  }
}

Termination by Bot

CloseEvent sent is as below

{
  "type": "playAudio",
  "data": {
    "audioContentType": "wave",
    "audioContent": "None",
    "textContent": "asr_disconnect=true"
  }
}

Call Transfer

Transfer Event

{
  "type": "playAudio",
  "data": {
    "audioContentType": "wave",
    "audioContent": "None",
    "textContent": "asr_disconnect=true,parameter1=default"
  }
}

Sending the above event will transfer the call to a default agent which is not added and managed by us.

Updated on October 26, 2023
Was this article helpful?

Related Articles

Not what you are looking for?
Click the link below to submit a support ticket
Submit Ticket
Schedule a demo

Get Started with Verloop.io