The OGo Asterisk Dialer
Download of the Asterisk Dialer plugin
- The Asterisk Dialer plugin can be downloaded from here
- This patch requires the patch uploaded to this bug report here (since OGO trunk version 2056, this patch is included and there is no need to apply it manually anymore)
- To enable the alternative client to phone mapping, you have to apply the patch to this bug report from here too.
Installation of the Asterisk Dialer
the patch above could be applied to the latest opengroupware trunk sources and installed the following way:
tar -xzf opengroupware.org-trunk.tar.gz patch -p0 < patchfile1 patch -p0 < patchfile2 cd opengroupware.org/WebUI/CTI/AsteriskDialer . /path/to/GNUstep.sh gmake -s install debug=yes strip=noNote:For the successful compilation, you need the libFoundation and sope header files installed.
Note:On some systems, "gmake" might be just a plain "make", make -v should produce sth. like "GNU Make ..." in the first line.
Activation of the Asterisk Dialer in SkyDialNumber
OGo is looking for CTI plugins on startup, and will show a list of found CTI Dialers at startup. In case you have more than one CTI Dialer installed, then you have to tell OGo, which one to use. To use the Asterisk Dialer you have to define the CTIDialer default as shown below. Setting this Default in case you only have the AsteriskDialer installed, doen't hurt.
Note: Before running the Defaults command you have to change the identity to the user that is later running the ogo binary using su or sudo. This user is usually named ogo, or on OpenBSD _ogo.Defaults write NSGlobalDomain CTIDialer AsteriskDialer
Mapping client users to telephones
There are two ways in mapping a client user to a telephone in the AsteriskDialer:
- using the Default CTIRemoteHostToDevice
- using the Defaults CTIPreferTelephoneField, CTIPersonTelephoneField, CTIPersonTelephoneFieldSuffix, CTIPersonTelephoneFieldPrefix together with the LSTeleType Default.
The first method is useful, when you have phone end devices that will not move, with desktops next to it, and maybe changing people using that Desktop. The key in the Default is the IP address of the Desktop (dynamic IP address assignment via DHCP or other methods will not work in this case), next to the Telephone. The value in the Default is the extension of the Telephone, next to the Desktop.
The second method is useful, when you have mobile telephones, e.g. notebook users using softphones. Then you have to define the Default CTIPersonTelephoneField to either a standard field name, or a new telephone field. In case you take a non standard field, you have to redefine the LSTeleType Default to include the new field in the Person subsection.
To enable the second method, you have to set the Default CTIPreferTelephoneField to YES. If you e.g. only have SIP/ or IAX/ devices, then you might define the Default CTIPersonTelephoneFieldPrefix appropriately. Then you only need to enter the extension in the specified LSTeleType field in the WebUI, as the SkyDialNumber class will prepend the value defined in CTIPersonTelephoneFieldPrefix and append the value defined in CTIPersonTelephoneFieldSuffix to the value stored in the defined CTIPersonTelephoneFieldPrefix field.
In case the Default CTIPersonTelephoneField is set to e.g. 04_tel_ext as above, then LSTeleType has to be set like the following to include the new Telephone type. The CTIRemoteHostToDevice Default in the example shows private IP address mappings to SIP telephone devices.
CTIRemoteHostToDevice = {
"10.0.0.9" = "SIP/100";
"10.0.0.10" = "SIP/200";
"10.0.0.11" = "SIP/300"; };
CTIPersonTelephoneField = 04_tel_ext;
CTIPersonTelephoneFieldSuffix = '""';
CTIPersonTelephoneFieldPrefix = SIP/
CTIPreferTelephoneField = YES;
LSTeleType = {
Enterprise = (
"01_tel",
"02_tel",
"10_fax",
"80_tel_parts",
"81_fax_parts"
);
Person = (
"01_tel",
"02_tel",
"03_tel_funk",
"04_tel_ext",
"05_tel_private",
"10_fax",
"15_fax_private"
);
};
Configuration of the Asterisk Dialer
The configuration of the connection to the Asterisk management interface is done via the OGoAsteriskConnectionDictionary Default. The hostname and port where the Asterisk Management Interface is listening has to be specified like in the example below: In the example we assume the Asterisk is running on the localhost and using the standard port. Thus, it is possible to specify an Asterisk on a remote host:
Defaults write NSGlobalDomain OGoAsteriskConnectionDictionary {hostName = localhost; port = 5038;}
The Asterisk Dialer has to be further configured via more Defaults. It is possible to add a prefix to numbers for outgoing calls, if necessary. This is done via the AsteriskDialOutPrefix. The decision whether a call is an internal or outgoing call is done on the length of the internal extensions, assuming that all internal extensions have the same length. For this purpose the AsteriskInternalExtensionLength Default is used. Furthermore the names of the outgoing and internal Asterisk dial plan contexts have to be defined. Therefore, the Defaults AsteriskInternalContext and AsteriskOutgoingContext are used. If you have only one context for everything, then you only need to define AsteriskInternalContext.
Defaults write NSGlobalDomain AsteriskInternalExtensionLength 3 Defaults write NSGlobalDomain AsteriskDialOutPrefix 0 Defaults write NSGlobalDomain AsteriskInternalContext internal Defaults write NSGlobalDomain AsteriskOutgoingContext outgoing
Last but not least, the commands that are sent to the Asterisk are stored as templates in the AsteriskCommands Default like this one below. Especially the Secret and Username for the Login Command have to match the configuration of the Asterisk Management Interface.
AsteriskCommands = { Login = { Action = login; ExpectedResult = Success; Parameters = { Events = off; Secret = AsteriskManagerPassword; Username = AsteriskManagerLogin; }; }; Originate = { Action = originate; ExpectedResult = Success; Parameters = { Channel = ""; Context = default; Exten = ""; Priority = 1; Timeout = 30000; }; }; Ping = { Action = ping; ExpectedResult = Pong; }; };
more on the asterisk management interface and its configuration can be found here
Trobleshooting
After installation, you should check whether the AsteriskDialer.cti bundle ended up in the correct location. You should change identity to the user usually running your OGo instance, and then start the WebUI manually. Already without any Defaults configured, OGo should find the AsteriskDialer and list it as an available CTI plugin like this:
$ /usr/local/sbin/ogo-webui-1.1 ... Dec 16 09:32:52 ogo-webui-1.1 [15429]: |ogo-webui-1.1| CTI Dialers: AsteriskDialer ...In case the AsteriskDialer is not listed in the CTI Dialers, then you have to track down the location where OGo searches for the CTI dialer plugins.
In case you do not have setup the OGoAsteriskConnectionDictionary correctly or did not defined it at all, then you will see output like below, in case you click on a telephone icon:
Dec 16 13:48:52 ogo-webui-1.1 [7335]: (1CA71CA70147651EA1) CTI device 'SIP/100': dialingIn above case, the OGoAsteriskConnectionDictionary was not defined at all.0012 3456789.. couldn't create socket: (Exception name:NGCouldNotConnectException class:NGCouldNotConnectException reason:Could not connect to address <0x0x7c4d8f64[NGInternetSocketAddress]: *host port=0>: the address length is invalid info:) Dec 16 13:48:52 ogo-webui-1.1 [7335]: -[AsteriskConnection _exceptionWithCode:]: made exception for code COULDNTCONNECT Dec 16 13:48:52 ogo-webui-1.1 [7335]: -[AsteriskDialer dialNumber:fromDevice:]: couldn't login to the asterisk 'SIP/100': (Exception name:AsteriskExceptioName class:NSException reason:COULDNTCONNECT info:{ code = COULDNTCONNECT; connection = ; port = 0; })
In case OGo is able to login to the Asterisk, then it comes to the OGoAsteriskCommands Default. In case the OGoAsteriskCommands Default is not defined, or e.g. the password to login is incorrectly specified, then when you click on a Telephone icon, something like that will show up in the WebUI logs, and an error window will appear:
Dec 16 13:52:12 ogo-webui-1.1 [29013]: (715571550147651F4E) CTI device 'SIP/100': dialing0012 3456789.. Dec 16 13:52:13 ogo-webui-1.1 [29013]: AsteriskDialer: will dial00123456789from deviceSIP/100