JavaScript

Create a client side application

Create an HTML file called client_js.html in your project directory. Add the following code, but make sure you paste in the JWT you generated for the user in the earlier step in this tutorial:

This is your web application that uses the Client SDK to accept an inbound call.

The main features of this code are:

  1. A notification box that can be updated with the call status.
  2. A button used when the agent wants to answer an inbound call.
  3. A button used when the agent wants to reject an inbound call.
  4. A button used when the agent wants to hang-up an inbound call.
  5. The code logs the agent in using the user JWT generated in an earlier step.
  6. The code sets up two main event handlers. The first is fired on the inbound call. This in turn sets up 3 click button event handlers which answers, rejects and hangs-up the inbound call using the Client SDK method call.answer(),call.reject(), and call.hangUp() respectively.
  7. The second, the call status changed (call:status:changed) event handler sets the text of the notification box to the inbound call status.