JavaScript
Create a local server using an ExpressJS application
To use an ExpressJS application:
- Create a new application using
npm init. - Install the ExpressJS library by using
npm install express --save - Write the code:
const express = require('express')
const app = express()
const port = 3000
app.post('/webhook', function(req, res, next) {
console.log(req.body)
res.send(200)
});
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
To start your application, run the following command:
node app.js
Your application will now print the events to the console when a call is made or received.
Note: Make sure the port you have specified (300) is the same port you use when creating your ngrok URL.
Receiving call events using webhooks
Create a webhook to receive events from calls
Steps
1
Introduction to this task2
Prerequisites3
Create a webhook4
Create a local server5
Create a webhook6
Cleanup7
What's next?