Dialproxy

General

The purpose is to trigger a call by first dialing a selected extension, when answered, the script completes and an outgoing call is initiated to the num=number. The Actionlist “DIALPROXY-value” key is used to define the extension and options.

Note → AstLinux 1.1.4 added the following features to dialproxy.php:

  • Support for POST method on addition to previous GET method.
  • Support for non-numeric num= (eg. +49 89-12345678), but must be urlencode'ed when passed.
  • E.164 number prefix filtering using DIALING_PREFIX_NUMBERS (rc.conf variable).

Typical uses:

GET Method:

$ curl "http://pbx/dialproxy.php?num=2223334444&ext=value"
$ curl --insecure "https://pbx/dialproxy.php?num=2223334444&ext=value"

Tip → Include &debug=1 for testing DIALING_PREFIX_NUMBERS prefix settings without dialing.

POST Method:

$ curl --data-urlencode 'num=2223334444' --data-urlencode 'ext=value' http://pbx/dialproxy.php
$ curl --data-urlencode 'num=2223334444' --data-urlencode 'ext=value' --insecure https://pbx/dialproxy.php

Tip → Include -d debug=1 for testing DIALING_PREFIX_NUMBERS prefix settings without dialing.

The num=number is the outbound call phone number. Be certain to urlencode any non-numeric number when passed.

The ext=value is a label that references a key in the Asterisk “AstDB” database. The actionlist key DIALPROXY-value must be defined, the required data is the initial phone extension to dial, such as SIP/1234. Additionally, tilde '~' separated options of:

Option Description
context=default The context to make the outgoing call from, defaults to 'default'
timeout=30 The amount to time to ring extension, defaults to '30' seconds
callerid= The outgoing Caller ID
localcallerid= The Caller ID for local (2-4 char) extension destinations
dialprefix= Dial Prefix (e.g. 0 or 9), overrides OutgoinglinePrefix, if set in DIALING_PREFIX_NUMBERS
allow= Allowed IP addresses which only have access, space-or-comma separated, defaults to everyone.

Actionlist DIALPROXY Example:

Actionlist

Tip → If you need to “do something” with your (originating) phone, before it answers, you can use local channels instead of e.g. a SIP channel, like:

DIALPROXY-999 => local/999@predial-context  

Note → Attempts to use dialproxy.php without a valid matching DIALPROXY-value actionlist entry will be logged to syslog including the offending HTTP remote IP address.

In Asterisk, the [webinterface] manager.conf context must include the permissions:

read = command,call,originate                               
write = command,call,originate

Dialing Prefixes

Support for International E.164 numbering can be simplified by defining the following Dialing Prefixes in your user.conf, which are then used by dialproxy.php:

Note: AstLinux 1.1.4 or later is required

## International E.164 dialing prefixes.  Currently used by dialproxy.php
## Define 4 ~ (tilde) separated arguments (all optional)
## Arg1: InternationalPrefix
## Arg2: NationalPrefix
## Arg3: CountryPrefix
## Arg4: OutgoinglinePrefix - dial prefix added to every number
## Germany example: "00~0~49~"
## Map '+44 123 12345678'  -> '004412312345678'
## Map '+49 89-12345678'   -> '08912345678'
## Map '+1 (222) 333-4444' -> '0012223334444'
##
#DIALING_PREFIX_NUMBERS="00~0~49~"

The (more specific) Actionlist DIALPROXY-value option “dialprefix=” has priority over the general “OutgoinglinePrefix”. So you could normally use “0” for an outgoing line in Dialproxy usage, but the DIALPROXY-office extension could use “9” instead.

Note → When DIALING_PREFIX_NUMBERS is defined the plus '+' character will not be filtered (unless acted upon by prefixes) and passed to the dialplan. When DIALING_PREFIX_NUMBERS is not defined (the default) only the characters 0123456789*# will be passed to the dialplan. If additionally the plus '+' character is desired to be passed to the dialplan without prefix filtering set:

DIALING_PREFIX_NUMBERS="~~~"

A typical application would allow an Address Book to support a link (URL), when clicked, to dial the phone number via a selected extension.

Examples

OS X “Address Book/Contacts” plugin example

Until 10.8.x it needs to be saved as “~/Library/Address Book Plug-Ins/DialProxy-office.scpt” (Thanks Michael Keuter)

Since 10.9.x it has to be in “~/Library/Application Scripts/com.apple.AddressBook/” instead and the application name should be “Contacts”.

using terms from application "Address Book"
	
	-- URL for AstLinux DialProxy
	property dialproxyUrl : "https://pbx/dialproxy.php"
	
	-- specify extension in actionlist DIALPROXY-key
	property myExtension : "office"
	
	on action property
		return "phone"
	end action property
	
	on action title for thePerson with phoneNumber
		return (value of phoneNumber as string) & " via " & myExtension
	end action title
	
	on should enable action for thePerson with phoneNumber
		return true
	end should enable action
	
	on perform action for thePerson with phoneNumber
		set myNumber to (value of phoneNumber as string)
		
		-- cleanup the phone number
		set myNumber to do shell script "echo '" & myNumber & "' | sed -e 's/[^0-9]//g'"
		
		-- generate URL for AstLinux DialProxy
		set dialUrl to dialproxyUrl
		set dialUrl to dialUrl & "?num=" & myNumber
		set dialUrl to dialUrl & "&ext=" & myExtension
		
		-- call URL using "curl"
		do shell script "curl --insecure '" & dialUrl & "' >/dev/null"
		
	end perform action
	
end using terms from

Thunderbird

There is a nice Thunderbird plugin TBDialOut which works fine with Dialproxy or AMI.
Note: Might not work with the latest Thunderbird versions because of the Add-on format change of Mozilla. Still works when installed manually in TB 52.8.0 Mac.

Firefox

For Firefox you could use Telify via Dialproxy or Noojee Click via AMI.
Note: Both won't work with the latest Firefox versions (57+) because of the Add-on format change of Mozilla.

Google Chrome

For Chome you could use Asterisk Click2Call with Dialproxy (AstLinux 1.2.5 is needed!).