Using Asterisk-Java to integrate with Asterisk
The ADempiere user wants to initiate a phone call to a customer from within ADempiere. She uses a SIP phone.
ADempiere talks to the Asterisk Manager API using the Asterisk-Java library (see http://asterisk-java.org). A request is sent to Asterisk to initiate a call to a certain phone number using a certain SIP phone. These data are passed via the interface.
The necessary data for a connection are
- the host identification where Asterisk is living
- the Asterisk user for authentication
- the related password
- the channel to connect the call to ("SIP/11" e.g.)
- the Asterisk context to be used
These are user specific. They could be maintained via an extra tab of the User window.
The phone numbers to be called are found either on business partner location (four different) or on business partner user/contact (two different).
- The user data will be kept within a new table named e.g. SIP_UserData.
CREATE TABLE SIP_UserData ( SIP_UserData_ID NUMBER(10,0), AD_CLIENT_ID NUMBER(10,0), AD_ORG_ID NUMBER(10,0), CREATED DATE , CREATEDBY NUMBER(10,0), UPDATED DATE, UPDATEDBY NUMBER(10,0), ISACTIVE CHAR(1 BYTE), AD_USER_ID NUMBER(10,0), SIP_HOST NVARCHAR2(32), SIP_USER NVARCHAR2(32), SIP_PASS NVARCHAR2(32), SIP_CHAN NVARCHAR2(32), SIP_CONTEXT NVARCHAR2(32) )
- The user data are maintained on a new tab of the User window.
- For the interaction with the Asterisk server the class AsteriskManager is used.
See contributions tracker item
- The method "initiateCall" can be used by a process (linked to a button) to send one of the phone numbers to Asterisk and connect to the defined channel for the user logged in to ADempiere.
Example code skeleton:
loc = MBPartnerLocation( C_BPartnerLocation_ID ); astExten = loc.getPhone(); astData = X_XX_Asterisk_Data( xx_asterisk_data_id ); astChannel = astData.getAstChan(); astContext = astData.getAstContext(); asteriskManager = AsteriskManager(astData.getAstHost(),astData.getAstUser(),astData.getAstPass()); result = asteriskManager.initiateCall(astChannel, astContext, astExten, astPrority, astTimeout);
- On the Asterisk side you have to put the necessary data into the configuration file manager.conf.
; ; Asterisk Call Management support ; [general] enabled = yes port = 5038 bindaddr = 10.1.1.100 permit = 0.0.0.0/0.0.0.0 [gardenuser] secret = gardenpass ;deny=0.0.0.0/0.0.0.0 ;permit=220.127.116.11/255.255.255.0 read = system,call,log,verbose,command,agent,user write = system,call,log,verbose,command,agent,user