Asterisk manager Example: Applescript

Asterisk Manager Example: Applescript

Dialing the Phone from OS X Addressbook using Applescript only!!

(Well "Expect" too but that's part of the OS so we won't worry too much about that!)

copy the code below into applescript and then save it into ~/Library/Address Book Plug-Ins/ you'll have to modify some of the vars in the script to match your env and yes I could have put them in a prefs file but.. I didn't so sue me! :p

Cheers, Zed@britewhite.net



using terms from application "Address Book"
on action property
return "phone"
end action property
on action title for p with e
return "Dial with VOIPv2"
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 DialOut(telephone)
set mynumber to 2000
set callerid to telephone
set username to "zed"
set passwd to "nottelling"
set remotehost to "pbxint"
set context to "inside"
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\";
send \"Action: originate
Exten: " & telephone & "
Context: " & context &"
Channel: SIP/" & mynumber & "
Priority: 1
Callerid: " & callerid & "

\";
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



Back

Asterisk Manager Example: Applescript

Dialing the Phone from OS X Addressbook using Applescript only!!

(Well "Expect" too but that's part of the OS so we won't worry too much about that!)

copy the code below into applescript and then save it into ~/Library/Address Book Plug-Ins/ you'll have to modify some of the vars in the script to match your env and yes I could have put them in a prefs file but.. I didn't so sue me! :p

Cheers, Zed@britewhite.net



using terms from application "Address Book"
on action property
return "phone"
end action property
on action title for p with e
return "Dial with VOIPv2"
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 DialOut(telephone)
set mynumber to 2000
set callerid to telephone
set username to "zed"
set passwd to "nottelling"
set remotehost to "pbxint"
set context to "inside"
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\";
send \"Action: originate
Exten: " & telephone & "
Context: " & context &"
Channel: SIP/" & mynumber & "
Priority: 1
Callerid: " & callerid & "

\";
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



Back

Created by: flobi, Last modification: Thu 25 of Aug, 2005 (14:18 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+