Vonage Cloud Runtime For Voice
To run any voice application it is required to have a web server that instructs the Vonage platform how to handle the call according to your use case, providing responses to answer and event webhook requests. For testing purposes, you can use, for example, ngrok or LocalTunnel. For production mode, you may use any cloud or on premise software of your choice.
Vonage Cloud Runtime lets you build Voice solutions without worrying about setting up hosting infrastructure.
Getting Started
You can create your application from scratch and host it on Cloud Runtime, or select one of pre-built templates on Code Hub to start with:
You can also create a backend application for calling with the Client SDK Sample Server template.
Follow the setup instructions for your selected use case to get started.
Handling Voice Webhooks
The Cloud Runtime SDK has a set of providers for different channels and purposes. The Voice provider allows to listen to answer and event webhooks:
const session = vcr.createSession();
const voice = new Voice(session);
await voice.onCall('onCall');
await voice.onCallEvent('onCallEvent');
app.post('/onCall', async (req, res, next) => {
res.json([
{
action: 'talk',
text: 'Hello from Vonage!'
}
]);
});
app.post('/onCallEvent', async (req, res, next) => {
console.log('Call Event: ', req.body);
});