How to dial all registered contacts of an account from Lua

This page describes how to make all phones (contacts) registered on an Asterisk account ring at the same time from within a Lua dial plan.

Note: This only works with PJSIP (, not with

The pieces

Lua dial plan example

The PJSIP object is the global channel hash! This is how it works.
# extensions.lua
local contacts = channel.PJSIP_DIAL_CONTACTS(extension):get()
app.dial(contacts, timeout, options)
However, there's a problem. If a call to a provider runs through this, PJSIP returns something like
pjsip_acf_dial_contacts_read: Specified endpoint 'PJSIP/20000@sipgate_trunk' was not found.
This is my workaround
# extensions.lua
-- workaround for "WARNING: Specified endpoint 'PJSIP/20000@sipgate_trunk' was not found"
-- I hope there's a better way, but I don't know it.
local contacts
if not string.find(extension, "_trunk$") then
    contacts = channel.PJSIP_DIAL_CONTACTS(extension):get() -- PJSIP-specific
if contacts == nil then contacts = extension end
app.dial(contacts, timeout, options)


Licensed under the Creative Commons Attribution-Share Alike 3.0 License.
Created 2018-04