Skip to main content
By the end of this guide, you will have a working web application that uses the Cognigy Click To Call SDK to establish a SIP-based voice call from the browser. You will install the SDK, verify browser compatibility, configure a client, and make your first call. The code examples in this guide use TypeScript. If you use plain JavaScript, remove the type annotations.

Prerequisites

  • A modern web browser with WebRTC support. For more information, refer to Supported Browsers.
  • Node.js version 18 or later.
  • A web application where you can install npm packages.
    • The web application must be served over HTTPS or from localhost. WebSocket and UDP traffic must be allowed for SIP signaling and media transport.
  • A Cognigy.AI Flow with a configured Voice Gateway Endpoint.

Install the SDK

  1. Install the SDK in your web application project using npm:
  2. Verify the installation:

Configure the Client

Import the SDK, verify browser support, and create a client instance:
The endpointUrl parameter must point to a valid Cognigy Voice Gateway Endpoint:
  1. In the Configuration section of the Voice Gateway Endpoint, copy the URL from the Endpoint URL field.
  2. Replace wss:// with https:// and remove /voiceGateway from the path. For example, if your Endpoint URL is:
    Then your endpointUrl will be:
The SDK fetches SIP credentials and server details from this URL automatically.

(Optional) Configure Custom STUN/TURN Servers

For advanced use cases, such as specifying custom STUN or TURN servers, provide a pcConfig object when creating the client. Use pcConfig only if your application requires custom NAT traversal or TURN servers. Otherwise, the SDK uses default servers automatically.

Register Event Listeners

Set up event listeners before making any calls:
Audio playback is automatic. You don’t need to add an <audio> element to your HTML. For advanced use cases, such as custom audio processing or visualization, refer to Custom Audio.

Start and End a Call

With the client configured and events registered, start a voice call:
To end the call and clean up:
Instead of calling endCall() and disconnect() separately, you can call client.destroy() to end the call, disconnect, and release all resources in one step.

Run and Verify

  1. Combine the code from the previous sections into a single function and bind it to a button click in your web application. A call must be initiated by a user gesture, for example, a button click, because browsers block audio autoplay without user interaction. Refer to the Complete Example.
  2. Start your application and open it in a supported browser.
  3. Open the browser developer console.
  4. Click the button that triggers the call. You should see the following messages in the console:
    • Connecting to SIP server... — the SDK is establishing a connection.
    • SIP client registered — registration succeeded.
    • Call answered. Session ID: ... — the call is active and audio should be playing.
If you don’t hear audio or the call fails to connect, refer to Troubleshooting.

Complete Example

Next Steps

Last modified on April 21, 2026