WSI: Pub/Sub
PortSIP PBX offers a Pub/Sub mechanism using WebSocket (PortSIP WSI). This allows users to subscribe to PBX events in any programming language. When subscribed events occur, PortSIP PBX automatically pushes event messages to subscribers in JSON format.
Support version: v16.0 or higher
Service Port
The PortSIP PBX/UCaaS provides WSI on port 8887 over WSS, the server must be allowed this port on the firewall for TCP, which requires WSS(TLS).
Server URL
The WSI Server URL varies between PortSIP PBX versions:
v22.0 or higher:
wss://pbx.portsip.com:8887/wsi
v16.x:
wss://pbx.portsip.com:8885
The WebSocket client application needs to connect to the appropriate URL. Please replace pbx.portsip.com
it with your actual PBX domain.
Topics and Message Type
PortSIP PBX provides the topics and keys for the Pub/Sub below.
global_extension_management_events
PBX System Administrators can subscribe to the global_extension_management_events
topic. Once subscribed, they'll receive real-time notifications whenever an extension is added, updated, or deleted.
The following message keys are included:
event_type
: Indicates the specific event:extension_created
extension_updated
extension_destroyed
extension_number
: The extension number.disp_name
: The display name of the extension.email
: The email of the extension.extension_id
: The ID of the extension.tenant_id
: The ID of the tenant associated with the extension.username
: The username of the extension.department
: The department of the extension; If it's not set, this key might not exist in the response JSON.
The extension_updated
event includes the same information as the extnesion_created
event.
extension_events
All extension-related event messages will be published under extension_events
. The following are the various message keys:
extension_status
This message will be returned under the following scenarios:
Upon successful subscription to an extension.
When a subscribed extension comes online.
When a subscribed extension goes offline.
The message is in JSON format and includes the following fields:
event_type
: Indicates the type of the message.tenant_id
: Represents the ID of the tenant to which the extension belongs.status
: It's a JSON array that includes the extension status, including the following fields:extension
: Represents the SIP URI of the extension.presence
: the presence status with the enum string:DO_NOT_DISTURB
AVAILABLE
AWAY
BUSINESS_TRIP
LUNCH
presence_note
: Contains the text of the additional presence status.call_status
: The "ON_CALL" status signifies that the extension is currently engaged in a call. The "RINGING" status means that the extension is currently receiving a call and is ringing. If this value is empty, it indicates that the extension is not involved in any call.online
: Indicates whether the extension is currently registered to the PBX.push_online
: This field indicates whether mobile push notifications are currently enabled for the extension. This is only valid ifonline
is false.extension_id
: Represents the ID of the extension.time
: Represents the timestamp of this message in UNIX time.
extension_call
This message will be returned under the following scenarios:
When an extension starts dialing a call.
When an extension receives a call.
When an extension disconnects a call.
The message is in JSON format and includes the following fields:
event_type
: Indicates the type of the message.extension
: Represents the SIP URI of the extension.call_status
: The "ON_CALL" status signifies that the extension is currently engaged in a call. The "RINGING" status means that the extension is currently receiving a call and is ringing. If this value is empty, it indicates that the extension is not involved in any call.tenant_id
: Represents the ID of the tenant to which the extension belongs.extension_id
: Represents the ID of the extension.time
: Represents the timestamp of this message in UNIX time.
extension_presence
This message will be returned under the following scenario:
When an extension changes its presence status.
The message is in JSON format and includes the following fields:
event_type
: Indicates the type of the message.extension
: Represents the SIP URI of the extension.presence
: the presence status with the enum string:DO_NOT_DISTURB
AVAILABLE
AWAY
BUSINESS_TRIP
LUNCH
presence_note
: Contains the text of the presence status.tenant_id
: Represents the ID of the tenant to which the extension belongs.extension_id
: Represents the ID of the extension.time
: Represents the timestamp of this message in UNIX time.
extension_agent_status
When an extension, is also an agent of the queue, who belongs to a queue to which a subscription has been made, changes their status within any of the queues they are associated with, a notification will be sent to the subscriber.
The message is in JSON format and includes the following fields:
event_type
: Indicates the type of the message.extension
: Represents the SIP URI of the extension.tenant_id
: Represents the ID of the tenant to which the extension belongs.extension_id
: Represents the ID of the extension.time
: Represents the timestamp of this message in UNIX time.agent_status
: A JSON array that contains the status of the queues:queue_number
: The extension number of the queuestatus
: the agent status of the queue
cdr_events
Once a call has ended, the CDR of this call will be pushed to the subscribers, this event means subscribing to all calls CDR of a tenant. The message topic is: cdr_events
, the message key is below.
call_start
: Once an extension receives a call, the call information will be packed in a JSON object and pushed to the subscriber.call_update_info
: The call information is updated, and the call information will be packed in a JSON object and pushed to the subscriber.call_cdr
: Once a call has ended, the CDR will be packed in a JSON object and pushed to the subscriber.
For more details about the CDR JSON object structure information, please refer to Event Reference.
queue_management_events
The tenant Admin and Queue Manager have permission to subscribe to the queue_management_events
. Once successfully subscribed, the PBX will push all current queue information to the subscriber. After that, during the subscription, whenever a queue is updated, deleted, or added, the subscriber will receive the queue information in real-time.
Below are the message keys.
event_type: Indicates the event type, it can have the following values:
queue_created
queue_updated
queue_destroy
queue_number: The extension number of the queue.
tenant_id: The ID of the tenant which this queue is belongs.
queue_events
Once the queue status is changed, for example, the caller who is in the queue has hung up the call, or the caller who is in the queue is answered by an agent, the related status information will be pushed to the subscribers. The message topic is queue_events.
Below are the message keys.
queue_status: If a subscriber successfully subscribed to queue events, the PBX will push the queue’s current status to the subscriber for all waiting for callers and agents. The
type
indicates that the waiting caller is active or is scheduled for a callback. The state of the agent can have the following values:Ready: The agent is ready to accept ACD calls.
Queue Call: The agent is on an ACD call.
Wrap Up: The agent is in ACW (After Call Work).
Other Call: The agent is on a non-ACD call.
Not Ready: The agent is not ready to accept ACD calls.
Logout: The agent has logged out from the queue.
Offline: The agent is offline.
queue_caller_status: if the waiting callers of a queue were changed, the PBX will push the queue_caller_status event in JSON format to the subscribers. The reason can be:
enqueue: This caller has just connected with the queue and is now on the waiting list.
agent_answered: The caller left the queue since it was answered by an agent.
overflow: The caller reached the maximum waiting time of the queue and was forwarded to the overflow destination.
hangup: The caller hung up.
callback: The caller has successfully scheduled a callback.
queue_agent_status: If an agent’s status in the queue changes, or a new agent is added to the queue, or an existing agent is removed from the queue, the PBX will push the queue_agent_status event in JSON format to the subscribers. The removed_agents field indicates the agents that have been newly removed from the queue.
queue_sla_breached: If a caller is waiting in the queue and the SLA is breached, the PBX will push a notification to subscribers in JSON format indicating that the queue SLA has been breached.
Authentication
Once connected to the WSI server, use the following JSON message to authenticate:
PBX System Administrator Authentication
The system administrator can currently subscribe only to extension management events. To subscribe to other events, a Tenant Admin or Queue Manager is required.
Tenant Admin Authentication
Tenant administrators can authenticate using either username/password or extension number/extension password.
Authenticate with Username
The domain
is the SIP domain of the extension, the password
is the user password
of extension.
Authenticate with Extension Number
You can authenticate using the SIP extension number and its corresponding password as well.
If there is no error, the response is as follows:
Otherwise, the response includes errors as below:
Subscribe and Unsubscribe
After successful authentication, the user can subscribe to events.
Subscribe to CDR Event
To subscribe to Call Detail Record (CDR) events, send the following command:
Subscribe to Extension Event
To subscribe to events for specific extensions, send the following command:
Subscribe to Global Extension Event
The PBX administrators can subscribe to this event by specifying the tenant IDs as a JSON array.
Subscribe to Global Extension Management Event
PBX System Administrators can subscribe to extension management events by specifying the tenant IDs as a JSON array.
Subscribe Queue Event
Subscription Limitations
Extension-Specific Subscriptions: Extensions can only subscribe to queues that they belong to or manage. If an extension is not an agent or queue manager of a queue, it cannot subscribe to that queue's events.
Tenant Admin and Queue Manager Permissions: Tenant Admin and Queue Manager users have the permission to subscribe to any queue wiin a tenant.
If extension 101 is an agent or queue manager of queues 8001 and 8002, and it subscribes to queue events using the following command:
Subscribe Global Queue Event
Only the PBX administrators can subscribe to this event.
Subscribe to Queue Management Event
Tenant Admin and Queue Manager users can subscribe to the queue_management_events
event.
Subscribe to Global Queue Management Event
Only the PBX Administrator can subscribe to this event.
Unsubscribe
To unsubscribe from all events, send the following command:
Last updated