Skip to content

KAZOO Support Channels

This documentation is curated by 2600Hz as part of the KAZOO open source project. Join our community forums here for peer support. Only features in the docs.2600hz.com/supported space are included as part of our 2600Hz Support Services plan.

Qubicle Websockets Setup#

Introduction#

This document will get a basic Websockets connection set up to the Qubicle event feed.

Prerequisites#

In order for the Websocket connections to work correctly, the Blackhole application must be started and the bh_qubicle module must be present and loaded.

Initiate Websocket connection#

Set up the Websocket connection to Blackhole

var ws = new WebSocket("ws://{SERVER}:5555");

// Connection Open Callback
ws.onopen = function() {
    console.log("Websocket connection is open.");
}

Subscribe to Qubicle events via Websocket#

Once the connection is successfully opened you must use a valid auth token to subscribe to Qubicle events. In this example a convenience function is created to help with the JSON formatting.

// Log Websocket data to console
ws.onmessage = function(ws_data) {
    var msg = JSON.parse(ws_data.data);
    console.log(ws_data.data);
}

function send(json) {
    ws.send(JSON.stringify(json));
}

// Subscribe for session events
send({"action":"subscribe", "auth_token": "{AUTH_TOKEN}", "data":{"account_id": "{ACCOUNT_ID}", "binding": "qubicle.session"}});

// Subscribe for recipient events
send({"action":"subscribe", "auth_token": "{AUTH_TOKEN}", "data":{"account_id": "{ACCOUNT_ID}", "binding": "qubicle.recipient"}});

// Subscribe for queue events
send({"action":"subscribe", "auth_token": "{AUTH_TOKEN}", "data":{"account_id": "{ACCOUNT_ID}", "binding": "qubicle.queue"}});