Skip to content

StasisBroadcast() - [app_stasis_broadcast]

Synopsis

Broadcast a channel to multiple ARI applications for claiming, then hand control to the winning application.

Since

20.17.0, 22.7.0, 23.1.0

Description

Broadcasts the incoming channel to all connected ARI applications (or a filtered subset) via a 'CallBroadcast' event. ARI applications can respond with a claim request. The first application to claim the channel wins, and subsequent claims are rejected.

If an application claims the channel within the timeout, the channel is automatically placed under Stasis control with the winning application, exactly as if 'Stasis(winner_app)' had been called. The winning application receives a 'StasisStart' event and has full channel control until it calls 'continue' or the channel hangs up.

If no application claims the channel within the timeout, control returns to the dialplan immediately, allowing fallback handling.

This application will set the following channel variables:

  • STASISSTATUS

    • SUCCESS - An application claimed the channel and the Stasis session completed without failures.

    • FAILED - An application claimed the channel but a failure occurred when executing the Stasis application.

    • TIMEOUT - No application claimed the channel within the timeout period.

      Example:
      ; Broadcast with default timeout (500ms) to all apps
      ; Channel automatically enters Stasis with the winner
      exten => _X.,1,StasisBroadcast()
      same => n,GotoIf($["${STASISSTATUS}"="TIMEOUT"]?no_route)
      same => n,Hangup()
      same => n(no_route),Playback(sorry-no-agent)
      same => n,Hangup()
      
      Example:
      ; Broadcast with custom timeout, app filter, and args for the winner
      exten => _X.,1,StasisBroadcast(2000,^ivr-.*,sales:priority-high)
      same => n,GotoIf($["${STASISSTATUS}"="TIMEOUT"]?no_route)
      same => n,Hangup()
      same => n(no_route),Playback(sorry-no-agent)
      same => n,Hangup()
      

Syntax

StasisBroadcast([timeout,[app_filter,[args,[notify_claimed]]]])
Arguments
  • timeout - Timeout in milliseconds to wait for a claim.
    Valid range: 0 to 60000ms
    Default: 500ms

  • app_filter - Regular expression to filter which ARI applications receive the broadcast. Only applications with names matching the regex will be notified.
    Because arguments are comma-delimited, commas cannot appear in the regex pattern. Use character classes (e.g. '[,]') if a literal comma is needed, or omit the filter and handle selection in the ARI application.
    Default: all connected applications

  • args - Optional colon-delimited arguments passed to the winning application via the 'StasisStart' event. These are equivalent to the extra arguments in 'Stasis()'.
    Example: 'sales:priority-high'

  • notify_claimed - Whether to send a 'CallClaimed' event to ARI applications when a channel is claimed.
    When enabled, the 'CallClaimed' event is sent only to applications that matched the app_filter (or all applications if no filter was set).
    Disabled by default to minimise WebSocket traffic under high load. Losing claimants already receive a '409' HTTP response.
    Default: no

Generated Version

This documentation was generated from Asterisk branch 20 using version GIT