Opentaps Asterisk Integration
From Opentaps Wiki
opentaps can be integrated with the Asterisk open source PBX which allows to call from opentaps using Asterisk and to be automatically prompted for the inbound caller in opentaps. This short tutorial teaches you how to configure the opentaps-Asterisk integration and how to use Asterisk from opentaps.
After opentaps 1.4 preview 2, voice over IP (VOIP) integration has been re-factored using the Domain Driven Architecture. The opentaps core supports a generic VOIP functionality, which allows you to make outbound VOIP calls from opentaps and prompts you for the caller of inbound calls in opentaps. The integration with asterisk is now in its own component as one implementation of this VOIP capability.
Configuring the Asterisk Server
First set up Asterisk by editing the file /etc/asterisk/manager.conf of your Asterisk server and add follow lines to create an manager account for opentaps connect:
;login account [eventsdaemon] ;login password secret = pa55w0rd321 ;permit network area permit = 0.0.0.0/0.0.0.0 ;listen events read = system,call,log,verbose,command,agent,user ;write events write = system,call,log,verbose,command,agent,user
First, configure opentaps to use asterisk for its VOIP functionality by editing the file hot-deploy/opentaps-common/config/domains-directory.xml:
<property name="voipDomain"><ref bean="opentapsAsteriskVoipDomain"/></property>
Next, edit the file hot-deploy/asterisk/config/voip.properties:
- Turn on voip integration by changing voip.enabled from N to Y
voip.enabled = Y
- Configure how frequently opentaps should check for new inbound calls from the asterisk server. By default, it's set to every three seconds:
voip.checkFrequencySeconds = 3
(In opentaps-1.4-preview-2 and earlier, you would need to edit hot-deploy/opentaps-common/config/asterisk.properties and set asterisk.enabled and asterisk.checkFrequencySeconds).
Next edit the file hot-deploy/asterisk/config/asterisk.properties in opentaps to connect it to Asterisk:
- Set up the asterisk server address and login credentials:
asterisk.host = asterisk.host.org asterisk.username = eventsdaemon asterisk.password = password
- Enter the telephone number associated with your asterisk server. This should be a Plain Old Telephone System (POTS) phone number that someone from the outside could call you on:
asterisk.countryCode = 1 asterisk.areaCode = 310 asterisk.phoneNumber = 9876543
- Now configure your outbound dialing prefrences. You need the outbound dialing prefix and additional prefix for calling long distance and foreign phone numbers:
asterisk.outbound.prev = 9 asterisk.outbound.area = 1 asterisk.outbound.foreign = 011
- In some places such as Los Angeles, you must always dial the area code, even when the phone number you are calling is in the same area code. These properties configure whether you must always dial the country or area code:
asterisk.alwaysDialCountryCode = Y asterisk.alwaysDialAreaCode = Y
Next, you would need to set up the extensions on the Asterisk PBX server for your opentaps users. In opentaps, you can assign a different user login to each unique extension. This can be done by modifying the ExternalUser entity in Web tools or its equivalent EXTERNAL_USER table in your database. You would need to enter the user login ID, externalUserTypeId of ASTERISK, the externalUserId with the asterisk extension. (Prior to opentaps-1.4-preview-2, this data was in the AsteriskUser entity or ASTERISK_USER table.)
Now you are ready. Restart opentaps, and let's see what it does!
Using Asterisk from opentaps
Making outbound calls is easy. Wherever you see a phone number with a link underneath it, you can click on the link, and opentaps will call out from your Asterisk servers using the extension associated with your user login. This should cause the Asterisk server to ring the handset configured to your extension:
All you have to do is pick up your phone, and the call is establish. If you are in the opentaps CRM application, opentaps will then take you to the screen for logging the call so that you can record this call:
Configuring Asterisk on Amazon Elastic Computing (EC2) Cloud
If you don't have an asterisk server, you can use one of the AMI images from resvoip. We used ami-2ec62147. This image sets up a virtual Linux server with asterisk preinstalled.
The only special configuration we found necessary when using Asterisk on the Amazon EC2 cloud was to edit the /etc/asterisk/sip_general_custom.conf file to configure both the external and internal IP addresses:
# your Amazon EC2 Internet IP externip = 174.123.456.789 # your Amazon EC2 local network setting localnet= 10.254.234.123/255.255.254.0
Also, the following ports need to be opened:
udp 10000-20000, 4569, 5036, 5060 tcp 5060, 5038 tcp 22, 80
Then, your opentaps instance can connect to the Asterisk server on Amazon EC2 through an SSH tunnel, like this:
$ ssh -i ~/ec2/asterisktest.pem -L 5038:ec2-174-123-456-789.compute-1.amazonaws.com:5038 email@example.com
Test your connection with:
$ telnet localhost 5038
If it's successful, then you should set your asterisk.host in asterisk.properties to localhost when configuring opentaps for Asterisk integration. (See above.)