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 16 or later to install and build your application. The SDK itself runs only in browsers.
  • 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 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. The userId parameter is optional. If you donโ€™t provide a userId, the SDK generates one.

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:
You can end a call only after the remote party has answered it. Calling endCall() while the call is still ringing fails with an error.
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. This message appears only for endpoints that require registration.
    • 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 October 23, 2026