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:
- A notification box that can be updated with the call status.
- A button used when the agent wants to answer an inbound call.
- A button used when the agent wants to reject an inbound call.
- A button used when the agent wants to hang-up an inbound call.
- The code logs the agent in using the user JWT generated in an earlier step.
- 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(), andcall.hangUp()respectively. - The second, the call status changed (
call:status:changed) event handler sets the text of the notification box to the inbound call status.
Receiving a phone call in-app
You receive a call from a phone to your app
Steps
1
Introduction to this task2
Prerequisites3
Create a webhook server4
Create a Vonage Application5
Buy a Vonage number6
Link a Vonage number7
Create a User8
Generate a JWT9
Create a client side application10
Run your application11
What's next?