VitalPBX Multi-Tenant Pushover Notifications

How to configure a system where calls to specific tenant/did/extension between a specific time or at any time (set in time condition) will trigger a Pushover notification (with Caller ID, DID, and Time) to a specific users mobile device as a push alert for notification or alerting purposes, then route the call to an IVR or Extension or Other External Destination. Useful for caller ID record keeping, call back emergencies or emergency mode in Pushover to force a phone out of silent mode in extreme emergencies. A custom Pushover user and key is set per tenant.

Note: You will need a pushover.net account and mobile app on ios or android. Generally either free or once off $5/£5 for lifetime use.


Phase 1: Global System Preparation (Super Admin)

These steps must be performed by the Main “Super Administrator” account.

1. Install the “Custom Contexts” Add-on

  1. Log in to the VitalPBX Main Tenant as admin.
  2. Navigate to Admin > Add-ons > Add-ons.
  3. Search for Custom Contexts and click Install.

2. Grant Permissions to Tenant Administrators

By default, Tenant Admins cannot see the “Custom Contexts” module. You must enable this.

  1. Navigate to Admin > Admin > User Profiles.
  2. Select the “Tenant Administrator” profile (or whichever profile your tenants use).
  3. Click the Module Access tab.
  4. Scroll down to the PBX section.
  5. Find Custom Contexts and check the “View”, “Create”, “Update”, and “Delete” boxes (or at least “View” and “Update”).
  6. Click Save and Apply Changes.

Phase 2: Server-Side Configuration (SSH)

These steps are done once via SSH to create the “engine” that powers the notifications.

1. Create the Generic Notification Script

This script is “tenant agnostic.” It simply takes keys and data as arguments and sends the alert.

SSH into your VitalPBX server.

Create the script file:

    nano /usr/local/bin/pushover_notify.sh

    Paste the following code:

    #!/bin/bash
    
    # --- INPUT VARIABLES (Passed from VitalPBX) ---
    CALLER_ID_NUM=$1
    CALLER_ID_NAME=$2
    DID_NUM=$3
    USER_KEY=$4
    APP_TOKEN=$5
    
    # --- CONFIGURATION (Customize Sound/Priority here) ---
    # Priority: 0 (Normal), 1 (High/Bypass Silent)
    PRIORITY="1"
    # Sound: pushover, bike, bugle, cashregister, classical, cosmic, falling, 
    # gamelan, incoming, intermission, magic, mechanical, pianobar, siren, 
    # spacealarm, tugboat, alien, climb, persistent, echo, updown, none
    SOUND="gamelan"
    
    # --- EXECUTION ---
    # Get current Server Time
    DATE_TIME=$(date "+%Y-%m-%d %I:%M %p")
    
    # Format the message body
    MESSAGE="Caller: $CALLER_ID_NAME ($CALLER_ID_NUM)
    Did: $DID_NUM
    Time: $DATE_TIME"
    
    TITLE="After Hours Call"
    
    # Send Request to Pushover
    curl -s \
      --form-string "token=$APP_TOKEN" \
      --form-string "user=$USER_KEY" \
      --form-string "message=$MESSAGE" \
      --form-string "title=$TITLE" \
      --form-string "priority=$PRIORITY" \
      --form-string "sound=$SOUND" \
      https://api.pushover.net/1/messages.json > /dev/null 2>&1

    Save and exit (Ctrl+O, Enter, Ctrl+X).

      Crucial: Make the script executable and secure:

        chmod +x /usr/local/bin/pushover_notify.sh
        chown asterisk:asterisk /usr/local/bin/pushover_notify.sh

        2. Configure the Dial Plan (Tenant Logic)

        This file maps specific tenants to their specific API keys.

        Edit the custom extensions file:

        nano /etc/asterisk/vitalpbx/extensions__90-custom.conf

        Add a context block for each tenant requiring this feature.

        ; =================================================
        ; TENANT A (e.g., Law Firm)
        ; =================================================
        [send-pushover-tenant-a]
        exten => s,1,NoOp(Sending Pushover for Tenant A)
        ; Syntax: script path, caller_num, caller_name, did, USER_KEY, APP_TOKEN
        same => n,System(/usr/local/bin/pushover_notify.sh "${CALLERID(num)}" "${CALLERID(name)}" "${CALLERID(dnid)}" "USER_KEY_A_HERE" "APP_TOKEN_A_HERE")
        same => n,Return()
        
        ; =================================================
        ; TENANT B (e.g., Medical Office)
        ; =================================================
        [send-pushover-tenant-b]
        exten => s,1,NoOp(Sending Pushover for Tenant B)
        same => n,System(/usr/local/bin/pushover_notify.sh "${CALLERID(num)}" "${CALLERID(name)}" "${CALLERID(dnid)}" "USER_KEY_B_HERE" "APP_TOKEN_B_HERE")
        same => n,Return()

        Save and exit.

        Reload Asterisk:

        asterisk -rx "dialplan reload"
        

        Phase 3: Tenant Configuration (GUI)

        Perform these steps INSIDE the specific Tenant’s dashboard.

        1. Switch to the Tenant

        • In the top-left dropdown menu of VitalPBX, select the specific Tenant (e.g., “Tenant A”).

        2. Create the Custom Context Link

        In this example its set to use an after hours IVR but you can use any number of other ways.

        1. Go to PBX > Applications > Custom Contexts.
        2. Description: After Hours Notify
        3. Context: send-pushover-tenant-a (Must match the [name] you put in the config file exactly).
        4. Destination:
          • Type: IVR
          • Destination: Select your “After Hours IVR” or “Main IVR”.
        5. Click Save and Apply Changes.

        3. Set Time Conditions (If required)

        1. Create Time Group:
          • Go to PBX > Incoming Call Tools > Time Groups.
          • Name: Overnight Shift
          • Start: 18:00 | Finish: 06:59
          • Save.
        2. Create Time Condition:
          • Go to PBX > Incoming Call Tools > Time Conditions.
          • Name: Check After Hours
          • Time Group: Overnight Shift
          • Destination if Match: Custom Contexts > After Hours Notify
          • Destination if No Match: Extensions > Receptionist (or standard day route).
          • Save.

        4. Update Incoming Route

        1. Go to PBX > Incoming Routes.
        2. Select the main trunk/DID route.
        3. Change Destination to Time Conditions > Check After Hours.
        4. Save and Apply Changes.

        Testing

        To test this without waiting for 6 PM:

        1. Create a temporary Misc Application (e.g., dial code *777).
        2. Point it directly to Custom Contexts > After Hours Notify.
        3. Dial *777 from a phone.
        4. Result: Your mobile should play the “Pushover” sound, display the notification with the current time, and your desk phone should immediately connect to the IVR. This should happen the instant the call connects.

        Similar Posts

        Leave a Reply