Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

sipgate logo Node.js incoming call example

This example demonstrates how to receive and process webhooks from

For further information regarding the push functionalities of please visit


  • Node.js >= 10.15.3

Enabling for your sipgate account

In order to use, you need to book the corresponding package in your sipgate account. The most basic package is the free S package.

If you use sipgate basic or simquadrat you can book packages in your product's feature store. If you are a sipgate team user logged in with an admin account you can find the option under Account Administration > Plans & Packages.

How webhooks work

What is a webhook?

A webhook is a POST request that makes to a predefined URL when a certain event occurs. These requests contain information about the event that occurred in application/x-www-form-urlencoded format.

This is an example payload converted from application/x-www-form-urlencoded to json:

  "event": "newCall",
  "direction": "in",
  "from": "492111234567",
  "to": "4915791234567",
  "user": [ "Alice" ],
  "xcid": "123abc456def789",
  "diversion": "1a2b3d4e5f"
} webhook events offers webhooks for the following events:

  • newCall: is triggered when a new incoming or outgoing call occurs
  • onAnswer: is triggered when a call is answered – either by a person or an automatic voicemail
  • onHangup: is triggered when a call is hung up
  • dtmf: is triggered when a user makes an entry of digits during a call

Note: Per default only sends webhooks for newCall events. To subscribe to other event types you can reply to the newCall event with an XML response. This response includes the event types you would like to receive webhooks for as well as the respective URL they should be directed to. You can find more information about the XML response here:

Configure webhooks for

You can configure webhooks for as follows:

  1. Navigate to and login with your sipgate account credentials.
  2. Select the Webhooks > URLs tab in the left side menu
  3. Click the gear icon of the Incoming or Outgoing entry
  4. Fill in your webhook URL and click save. Note: your webhook URL has to be accessible from the internet. (See the section Making your computer accessible from the internet)
  5. In the sources section you can select what phonelines and groups should trigger webhooks.

Making your computer accessible from the internet

There are many possibilities to obtain an externally accessible address for your computer. In this example we use the service which sets up a reverse ssh tunnel that forwards traffic from a public URL to your localhost. The following command creates a subdomain at and sets up a tunnel between the public port 80 on their server and your localhost:8080:

$ ssh -R 80:localhost:8080

If you run this example on a server which can already be reached from the internet, you do not need the forwarding. In that case, the webhook URL needs to be adjusted accordingly.


Create the .env by copying the .env.example and set the value according to the comment above. For more information read Configure webhooks for and Making your computer accessible from the internet.

Install dependencies:

Navigate to the project's root directory and run:

npm install


Run the application:

node index.js 

Deployment to Google Cloud App Engine

To deploy this project to Google Cloud App Engine, you might use our sipgateio-google-deployer.

How It Works

At first we create an HTTP server using the Express framework:

const express = require('express');
const app = express();

We then attach a middleware that converts the urlencoded payload of incoming webhooks to JavaScript objects making it accessible as request.body. The necessary function is also provided by the Express framework. The option extended: true enables the correct mapping of object structures, such as arrays.

app.use(express.urlencoded({ extended: true }));

The post() method on the app object registers a callback function that is executed when receiving a POST request on the route /. After logging the request body to the console the server should send a response without content.'/', (request, response) => {

Lastly, the Express app should listen on the specified port:

const port = process.env.WEBHOOK_PORT;
app.listen(port, () => {
	console.log('Server listening on: http://localhost:%s', port);

Common Issues

web app displays "Feature not booked."

Possible reasons are:

  • the feature is not booked for your account

See the section Enabling for your sipgate account for instruction on how to book

"Error: listen EADDRINUSE: address already in use :::{port}"

Possible reasons are:

  • another instance of the application is already running
  • the specified port is in use by another application

"Error: listen EACCES: permission denied{port}"

Possible reasons are:

  • you do not have permission to bind to the specified port. This usually occurs if you try to use port 80, 443 or another well-known port which can only be bound with superuser privileges

Call happened but no webhook was received

Possible reasons are:

  • the configured webhook URL is incorrect
  • the SSH tunnel connection broke
  • webhooks are not enabled for the phoneline that received the call


Contact Us

Please let us know how we can improve this example. If you have a specific feature request or found a bug, please use Issues or fork this repository and send a pull request with your improvements.


This project is licensed under The Unlicense (see LICENSE file).

External Libraries

This code uses the following external libraries | @sipgateio | API-doc


A demonstration of how to receive and process webhooks from







No releases published


No packages published