Integration of Asterisk_Click2Dial with Openerp


#1

Here are the softwares used in my server running on CentOS5.6
Elastix
Openerp v6.03
Asterisk 1.8.5

#vi /etc/asterisk/manager.conf
[neohs]
secret = elastix456
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
[root@elastix bin]# vi /etc/asterisk/extensions.conf


;this is where the extension has been included for openerp

[callanthony]
exten => s,1,AGI(/usr/local/bin/get_cid_name_timeout.sh)
exten => s,n,Answer()
exten => s,n,Hangup()

Use telnet to get connected to asterisk server OK. The phone can ring.

[root@elastix bin]# telnet localhost 5038
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
Asterisk Call Manager/1.1
Action: login
Events: off
Username: neohs
Secret: elastix456

Response: Success
Message: Authentication accepted

Action: originate
Channel: SIP/105
Timeout: 15000
CallerId: device
Exten: 105
Context: callanthony
Port:
Variable: SIPAddHeader=Alert-Info:
Priority: 1

Response: Success
Message: Originate successfully queued

Use the above configuration under asterisk server module in openerp but when I click on the Dial button next to phone number, the phone does not ring.

I suspect that Asterisk does not listen to Openerp calls.
I had to check a log file and here is the below info given under /etc/asterisk/full
[root@elastix bin]# tail /var/log/asterisk/full
[Sep 23 16:55:43] ERROR[7433] utils.c: fwrite() returned error: Broken pipe
[Sep 23 16:55:43] ERROR[7433] utils.c: fwrite() returned error: Broken pipe

The callerID name retrieved from postgresql is correct.
[root@elastix bin]# echo “agi_callerid:90624847”| /usr/local/bin/get_cid_name.py -s localhost -d openerp -u 3 -w "demo"
full AGI environnement :
agi_callerid = 90624847
stdout encoding = UTF-8
VERBOSE "CallerID number = 90624847"
phone number sent to OpenERP = 90624847
VERBOSE "Starting XML-RPC request on OpenERP localhost:8069"
VERBOSE "End of XML-RPC request on OpenERP"
VERBOSE "CallerID Name = Joseph"
SET CALLERID “Joseph”<90624847>

Here is the asterisk server configuration in openerp.
Asterisk servers Help Asterisk server name : Mind Asterisk server

Company ? : Mind & Media
Asterisk server name ? : Mind Asterisk server Active ? : *
Asterisk IP addr. or DNS ? : localhost Port ? : 5038
AMI login ? : neohs AMI password ? : **********
Dialplan context ? : callanthony Extension priority ? : 1
Out prefix ? : 9 National prefix ? : 0
International prefix ? : 00 My country prefix ? : 65
National format allowed ? ? : Alert-Info SIP header ? :
Wait time (sec) ? : 15

How to get the asterisk server to listen to Openerp so that the phone can ring upon the clicking of the DIAL button provided by asterisk_click2dial? If you can integrate asterisk_click2dial with openerp successfully, please share with us. Thank you

From Robert Neo from Singapore


#2

The errors in the coding have been discovered.

def action_dial_phone(self, cr, uid, ids, context=None):
...

def action_dial_mobile(self, cr, uid, ids, context=None):
....

These functions are extracted from asterisk_click2dial.py. They does not return values But they are supposed to return values at the end of these function. Those knowing python are free to comment on this.


#3

Must kill process id running under port 8069 and 8071 that are used for xmlprc. xmlrpc is used for communication between asterisk server and openerp.

It will solve the dial issue in openerp.


#4

Must kill process id running under port 8069 and 8071 that are used for xmlprc if they are running. Uncomment the xml-rpc in openerp-server.conf. Restart opemerp server, openerp-web and apache2. Start Openerp. Either of these ports will run automatically.

Xmlrpc is used for communication between asterisk server and openerp.

It will solve the dial issue in openerp. :stuck_out_tongue:


#5

The integration of Asterisk_click2dial with Openerp works well especially dialling out to people.

Elastix is just a GUI for configuring asterisk settings.

However, i got the issue on the display of caller name in openerp when a phone call comes.
I run agi-callerid command and the name of the caller is displayed correctly on screen.

root@MMelastix cdr-csv]# echo “agi_callerid:81018912”| /usr/local/bin/timeout 1s /usr/local/bin/get_cid_name.py -s 10.0.0.160 -d demo3 -u 3 -w "demo"
full AGI environnement :
agi_callerid = 81018912
stdout encoding = UTF-8
VERBOSE "CallerID number = 81018912"
phone number sent to OpenERP = 81018912
VERBOSE "Starting XML-RPC request on OpenERP 10.0.0.160:8069"
VERBOSE "End of XML-RPC request on OpenERP"
VERBOSE "CallerID Name = Ben Teo"
SET CALLERID “Ben Teo”<81018912>

When I dial to 654710XX, it is automatically directed to my extension number 105 and the phone under extension 105 rings. However, the name of the caller does not show up in openerp.

[size=85]MMelastix*CLI>asterisk -rvvvvvvvvvvvv
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [31520152@from-trunk:1] Set(“SIP/aaa-0000000a”, “__FROM_DID=31520152”) in new stack
– Executing [31520152@from-trunk:2] Gosub(“SIP/aaa-0000000a”, “app-blacklist-check,s,1”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“SIP/aaa-0000000a”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“SIP/aaa-0000000a”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“SIP/aaa-0000000a”, “”) in new stack
– Executing [31520152@from-trunk:3] ExecIf(“SIP/aaa-0000000a”, “1 ?Set(CALLERID(name)=1000)”) in new stack
– Executing [31520152@from-trunk:4] Set(“SIP/aaa-0000000a”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [31520152@from-trunk:5] Set(“SIP/aaa-0000000a”, “CALLERPRES()=allowed_not_screened”) in new stack
– Executing [31520152@from-trunk:6] Goto(“SIP/aaa-0000000a”, “ext-group,600,1”) in new stack
– Goto (ext-group,600,1)
– Executing [600@ext-group:1] Goto(“SIP/aaa-0000000a”, “from-internal2,s,1”) in new stack
– Goto (from-internal2,s,1)
– Executing [s@from-internal2:1] AGI(“SIP/aaa-0000000a”, “/usr/local/bin/get_cid_name_timeout.sh”) in new stack
– Launched AGI Script /usr/local/bin/get_cid_name_timeout.sh
– <SIP/aaa-0000000a>AGI Script /usr/local/bin/get_cid_name_timeout.sh completed,[color=#FF4040] returning 0[/color]
– Executing [s@from-internal2:2] Dial(“SIP/aaa-0000000a”, “SIP/105, 15”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called SIP/105
– SIP/105-0000000b is ringing
– SIP/105-0000000b answered SIP/aaa-0000000a
– Locally bridging SIP/aaa-0000000a and SIP/105-0000000b
== Spawn extension (from-internal2, s, 2) exited non-zero on ‘SIP/aaa-0000000a’[/size]

Looks like the script has been executed but the red highlight means that the caller number can’t be found in the database?

Here are my configurations for your assistance to identify issues.
extensions_additional.conf

[ext-group]
include => ext-group-custom
exten => 600,1(dest-ext),Goto(from-internal2,s,1)

extensions_custom.conf

[from-internal2]
exten => s,1,AGI(/usr/local/bin/get_cid_name_timeout.sh)
exten => s,n,Dial(SIP/105, 15)
exten => s,n,Answer()
exten => s,n,Voicemail(105@device,u)
exten => s,n,Hangup()

I need to get the caller name displayed when there is a coming call.
Please help to resolve this issue.
Thanks


#6

The result 0 is returned when the AGI script is run successfully. However, the postgres does not generate logs though the AGI script calls for the postgres database.

I suspect that the postgres could not be connected. Care to check if u could help to resolve this issue.
Thanks


#7

With assistance from Alexis De Lattre who is the author of the module on Asterisk_for_Click2Dial, the problem has been resolved. The caller name appeared correctly on the screen of my office phone when I dialled to it. Many thanks to Alexis De Lattre.

Here is the agi result.

[size=85]-- Executing [31520152@from-trunk:4] Set(“SIP/aaa-00000004”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [31520152@from-trunk:5] Set(“SIP/aaa-00000004”, “CALLERPRES()=allowed_not_screened”) in new stack
– Executing [31520152@from-trunk:6] Goto(“SIP/aaa-00000004”, “ext-group,600,1”) in new stack
– Goto (ext-group,600,1)
– Executing [600@ext-group:1] Goto(“SIP/aaa-00000004”, “from-internal2,s,1”) in new stack
– Goto (from-internal2,s,1)
– Executing [s@from-internal2:1] AGI(“SIP/aaa-00000004”, “/usr/local/bin/get_cid_name_timeout.sh”) in new stack
– Launched AGI Script /usr/local/bin/get_cid_name_timeout.sh
<SIP/aaa-00000004>AGI Tx >> agi_request: /usr/local/bin/get_cid_name_timeout.sh
<SIP/aaa-00000004>AGI Tx >> agi_channel: SIP/aaa-00000004
<SIP/aaa-00000004>AGI Tx >> agi_language: en
<SIP/aaa-00000004>AGI Tx >> agi_type: SIP
<SIP/aaa-00000004>AGI Tx >> agi_uniqueid: 1318914998.4
<SIP/aaa-00000004>AGI Tx >> agi_version: 1.8.5.0
<SIP/aaa-00000004>AGI Tx >> agi_callerid: 1000
<SIP/aaa-00000004>AGI Tx >> agi_calleridname: 1000
<SIP/aaa-00000004>AGI Tx >> agi_callingpres: 0
<SIP/aaa-00000004>AGI Tx >> agi_callingani2: 0
<SIP/aaa-00000004>AGI Tx >> agi_callington: 0
<SIP/aaa-00000004>AGI Tx >> agi_callingtns: 0
<SIP/aaa-00000004>AGI Tx >> agi_dnid: 31520152
<SIP/aaa-00000004>AGI Tx >> agi_rdnis: unknown
<SIP/aaa-00000004>AGI Tx >> agi_context: from-internal2
<SIP/aaa-00000004>AGI Tx >> agi_extension: s
<SIP/aaa-00000004>AGI Tx >> agi_priority: 1
<SIP/aaa-00000004>AGI Tx >> agi_enhanced: 0.0
<SIP/aaa-00000004>AGI Tx >> agi_accountcode:
<SIP/aaa-00000004>AGI Tx >> agi_threadid: 1088756032
<SIP/aaa-00000004>AGI Tx >>
<SIP/aaa-00000004>AGI Rx << VERBOSE “CallerID number = 1000”
/usr/local/bin/get_cid_name_timeout.sh: CallerID number = 1000
<SIP/aaa-00000004>AGI Tx >> 200 result=1
<SIP/aaa-00000004>AGI Rx << VERBOSE “Starting clear XML-RPC request on OpenERP 10.0.0.160:8069”
/usr/local/bin/get_cid_name_timeout.sh: Starting clear XML-RPC request on OpenERP 10.0.0.160:8069
<SIP/aaa-00000004>AGI Tx >> 200 result=1
<SIP/aaa-00000004>AGI Rx << VERBOSE “End of XML-RPC request on OpenERP”
/usr/local/bin/get_cid_name_timeout.sh: End of XML-RPC request on OpenERP
<SIP/aaa-00000004>AGI Tx >> 200 result=1
<SIP/aaa-00000004>AGI Rx << VERBOSE “CallerID Name = Zen 1000”
/usr/local/bin/get_cid_name_timeout.sh: CallerID Name = Zen 1000
<SIP/aaa-00000004>AGI Tx >> 200 result=1
<SIP/aaa-00000004>AGI Rx << SET CALLERID " Zen 1000"<1000>
<SIP/aaa-00000004>AGI Tx >> 200 result=1
– <SIP/aaa-00000004>AGI Script /usr/local/bin/get_cid_name_timeout.sh completed, returning 0
– Executing [s@from-internal2:2] Dial(“SIP/aaa-00000004”, “SIP/105, 15”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called SIP/105
– SIP/105-00000005 is ringing
== Spawn extension (from-internal2, s, 2) exited non-zero on ‘SIP/aaa-00000004’

doing dnsmgr_lookup for ‘sip.pfingo.com’[/size]