Skip to main content

Webhook server to dynamically route Voys calls to on-call PagerDuty users.

Project description

python3-cyberfusion-pagerduty-voys-webhook

Webhook server to dynamically route Voys calls to on-call PagerDuty users.

This webhook server is intended to route phone calls (handled by VoIP provider Voys) to users that are on-call on PagerDuty - without having to keep both in sync manually.

When using the webhook offered by this program in your Voys dial plan (see instructions under 'Configure'), calls are routed to the phone number specified in the PagerDuty user's 'Notification Rules'.

If multiple PagerDuty users are on-call, calls are routed to a random user. If the chosen PagerDuty user has multiple phone numbers, a random one is chosen.

Install

PyPI

Run the following command to install the package from PyPI:

pip3 install python3-cyberfusion-pagerduty-voys-webhook

Debian

Run the following commands to build a Debian package:

mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
dpkg-buildpackage -us -uc

Configure

  • Place your PagerDuty API key in /etc/pagerduty-voys-webhook/api_key (regular text file). See instructions under 'Configure'.
  • Place a randomly generated secret key in /etc/pagerduty-voys-webhook/secret_key (regular text file). When calling the webhook, this key must be specified - as a security measure. For example, you can generate a random secret using openssl: openssl rand -hex 32
  • Place the escalation policy ID in /etc/pagerduty-voys-webhook/escalation_policy_id (regular text file). Users to route calls to are retrieved from this escalation policy. For example, if you have a group of Customer Liaisons to route calls to, you can create a dedicated escalation policy for them.

Usage

Run

The webhook server runs on :::5839.

Manually

Run the app using an ASGI server such as Uvicorn.

systemd

systemctl start pagerduty-voys-webhook-server.service

SSL

Use a proxy that terminates SSL. E.g. HAProxy.

Example HAProxy config

frontend fr_ssl
  bind :::5840 v4v6 ssl crt /etc/ssl/certs/example_com.pem alpn h2,http/1.1 curves secp384r1:secp224r1
  mode http
  use_backend bk_pagerduty_voys_webhook_server

backend bk_pagerduty_voys_webhook_server
  mode http
  balance source
  server localhost ::1:5839 check

Configure

Create PagerDuty API key

  • Log in to PagerDuty.
  • Navigate to Integrations -> API Access Keys.
  • Click 'Create New API Key'.
  • For 'Description', fill in a free-form description.
  • Tick 'Read-only API Key'.
  • Click 'Create Key'.

Add webhook in Voys Freedom

  • Log in to Voys Freedom.
  • Navigate to Admin -> Webhooks.
  • Click 'Add'.
  • For 'Name', fill in a free-form name.
  • For 'Caller id forwarding', select whichever option suits your use case. This option controls which phone number the person sees who the call is routed to.
  • Set 'URL template' to: the URL on which this program runs + /voys-webhook?secret_key= + secret key (from /etc/pagerduty-voys-webhook/secret_key). For example: https://voys-webhook.example.com/voys-webhook?secret_key=r6cZPVkZdqujY6dME5uqDytK

Use webhook in dial plan

  • Log in to Voys Freedom.
  • Navigate to your dial plan.
  • Click 'Edit dial plan'.
  • Click 'add step'.
  • Select your newly added webhook.
  • In the 'HTTP and IVR success' branch, click 'Edit' next to 'Unfilled step'.
  • Select 'Variable destination'.

Optionally, you can specify 'fallback' steps in the 'HTTP or IVR failed' branch. For example, if the specified secret key is invalid, or this program doesn't (properly) respond for any other reason.

For more information, see Voys' own documentation on https://help.voys.nl/integraties-koppelingen-webhooks/webhooks.

(Optional) IP-restrict webhook request

This program returns phone numbers, which might be considered confidential/sensitive.

Although this program requires a secret key for webhook calls, it's recommended to restrict requests to Voys' IP addresses.

Find Voys' outgoing IP addresses here: https://help.voys.nl/netwerk-trunk-videobellen-en-ata/firewall-instellen

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file python3_cyberfusion_pagerduty_voys_webhook-1.1.2.tar.gz.

File metadata

File hashes

Hashes for python3_cyberfusion_pagerduty_voys_webhook-1.1.2.tar.gz
Algorithm Hash digest
SHA256 2345bd258b52f0ceb8097f1250a1d6afa04b4f0f0c37766756639422d39e0059
MD5 9f8cd4ebaa1e9f9b4b3fa8d7d6cab632
BLAKE2b-256 c2630b7caca71b0492f47fdf3ece4c226fb61ccf2b5e67dc5a35c4dc6ec6bcd5

See more details on using hashes here.

File details

Details for the file python3_cyberfusion_pagerduty_voys_webhook-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python3_cyberfusion_pagerduty_voys_webhook-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a961567c5cbd43276ac4c4ee4169c472926c44b5b5785483adc3e7cab6aefaf
MD5 961ad636e6f061ec838d097eff2f0ac4
BLAKE2b-256 a6e452867f0f2368ee038b19c848d3a34e3508b5a06109a5c3b8b01af4edd384

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page