

Each of these resources has a listen() method in the JavaScript SDK, which you need to call in order to start your websocket. Websocket listeners can be created for memberships, rooms, or messages. Websockets are created programmatically with the help of the JavaScript SDK, as they're a unique concept that requires additional behind the scenes setup. Websockets are not created by sending a POST request to the API like you would to create a webhook.

In this post, we will walk you through creating and using websockets to listen for events sent from Webex. Websockets are persistent connections established over HTTP that allow direct communication between servers (the Webex API in this case) and clients (the Webex JavaScript SDK).

To get around this problem, we recently introduced functionality in the Webex JavaScript SDK that allows applications to "listen" for Webex messaging events using websockets, a technology that does not require a web server running on a public IP address. This approach can be a problem though if your app needs to run behind a corporate firewall or in restrictive environments. When your application runs as a web server using a publicly-accessible URL, you don’t need to do much else beyond creating a webhook and having an app running at the webhook's targetUrl to process the webhook payload. When the registered event has occurred - for example a message was created or a membership was deleted - an HTTP POST event with a JSON payload is sent and your application can react to it accordingly. Webhooks are registered on resources like ‘messages’ or ‘memberships’ to notify applications of events on these resources. Most developers who have created applications for Webex are familiar with the concept of Webhooks.
