Odd behaviour when dialing via call manager

We are integrating an applescript with address book to dial phone numbers.

This is working but has a small problem…

When you click to dial in the address book, the system connects to call manager and submits the commands to initiate the dial. Now, my sip phone rings and I pick up at which point the outside number is dialed.

But, here’s the kicker…

If I call my personal Cingular everything works perfect.
If I call my work Sprint cellular phone it goes directly to my OGM for voice mail.
If I call a coworkers personal Verizon cellular, it goes directly to his password challenge for his voice mail. Not even his OGM.

Anyone know why this might be? We’d love to have this feature working properly but it isn’t.

This is on Asterisk 1.4.17

This is a test of a sprint call:

[b]pbxboxCLI>
== Parsing ‘/etc/asterisk/manager.conf’: Found
== Manager ‘toolcase’ logged on from 192.168.105.246
> Channel SIP/41-08945520 was answered.
– Executing [9999/7203185757@default:1] NoOp(“SIP/41-08945520”, “7203185756”) in new stack
– Executing [9999/7203185757@default:2] Dial(“SIP/41-08945520”, “Zap/G1/7203185757”) in new stack
– Requested transfer capability: 0x00 - SPEECH
– Called G1/7203185757
– Zap/23-1 is proceeding passing it to SIP/41-08945520
– Zap/23-1 is making progress passing it to SIP/41-08945520
– Zap/23-1 is ringing
– Zap/23-1 answered SIP/41-08945520
– Hungup ‘Zap/23-1’
== Spawn extension (default, 9999/7203185757, 2) exited non-zero on 'SIP/41-08945520’
pbxbox
CLI>

[/b]This went directly to the OGM in voice mail.

Now, here’s an example with the Cingular:

== Parsing ‘/etc/asterisk/manager.conf’: Found
== Manager ‘toolcase’ logged on from 192.168.105.246
> Channel SIP/41-08945520 was answered.
– Executing [9999/3035885910@default:1] NoOp(“SIP/41-08945520”, “3035885908”) in new stack
– Executing [9999/3035885910@default:2] Dial(“SIP/41-08945520”, “Zap/G1/3035885910”) in new stack
– Requested transfer capability: 0x00 - SPEECH
– Called G1/3035885910
– Zap/23-1 is proceeding passing it to SIP/41-08945520
– Zap/23-1 is making progress passing it to SIP/41-08945520
– Zap/23-1 is ringing
– Hungup ‘Zap/23-1’
== Spawn extension (default, 9999/3035885910, 2) exited non-zero on 'SIP/41-08945520’

The cellphone rings as expected and if I answer it everything works as expected.

Here’s the applescript we’re using

[code]using terms from application "Address Book"
on action property
return "phone"
end action property
on action title for p with e
return "Dial with Asterisk"
end action title
on should enable action for p with e
if value of e is missing value then
return false
else
return true
end if
end should enable action
on perform action for p with e
set telephone to value of e
set resultList to DialOut(telephone)
return true
end perform action

end using terms from

on replace_chars(this_text, search_string, replacement_string)
set AppleScript’s text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript’s text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript’s text item delimiters to ""
return this_text
end replace_chars

on DialOut(telephone)
set mynumber to 41
set callerid to telephone
set username to "username"
set passwd to "secretword"
set remotehost to "pbxbox"
set context to "default"
set numbertocall to replace_chars(telephone, “(”, “”)
set numbertocall to replace_chars(numbertocall, “)”, “”)
set numbertocall to replace_chars(numbertocall, " ", “”)
set numbertocall to replace_chars(numbertocall, “-”, “”)
set expectscript to "set timeout 20;
spawn telnet " & remotehost & " 5038;
expect “Asterisk Call Manager/1.0”;
send "Action: login
username: " & username & "
secret: " & passwd & "

";
expect “Message: Authentication accepted”;
sleep 1;
send “Action: originate
Exten: 9999/” & numbertocall & "
Context: " & context & “
Channel: SIP/” & mynumber & “
Priority: 1
Callerid: AB Dialed Entry <” & callerid & ">

";
sleep 1;
send "Action: logoff

“;

set results to do shell script "/usr/bin/expect -c  '" & expectscript & "'"
-- if (results is not equal to "") then display dialog results

end DialOut[/code]

Thanks!

Robert[/code]

RESOLVED

RESOLVED

The issue was the applescript was setting the callerid variable to the value of the phone number being called.

This made the cell phone services think the cell phone was calling itself and rolling over into voice mail.

The solution was to set the callerid to a static variable as such:

on DialOut(telephone)
	set mynumber to 41
	set callerid to "7204304000"
	set username to "username"
	...

Hope this helps someone else!!!

Robert