2010-01-21, 00:42
Im running an Asterisk VoIP server at my home to play with and test possible things that i can make out of it. I managed to make incoming calls show a notification msg on my XBMC (TV) screen showing the incoming call's number, but i want to do more with my media center (such as what LinuxMCE offers) as to initiate calls from my screen using the remote (dont really know how useful this is, since in order to talk on the phone i will be using my voip phone) but just to explore possibilities. Anyways i came across this python script which allows to initiate a call to a given extension / number and direct it to a specific extension (i.e. the phone set next to me - again why wouldn't i just pick up the phone next to me and dial the number from it - really dont know but as i said, im just exploring possibilities).
Here is the script, without any xbmc integration or even being a plugin in its current form:
my next step is add it as a programs plugin, in which i will enter the extension im i want to make my call from, and also enter (or select from a telephone directory) the number i want to dial.
Note: in order for this script to work, some modifications need to be done to asterisk's manager.conf as in to allow telneting into the server:
again, if anyone has any thoughts on how to make this useful, let me know, maybe we could make something out of this.
Here is the script, without any xbmc integration or even being a plugin in its current form:
Code:
import socket
HOST="192.168.1.123"
PORT=5038
p = """Action: login
Events: off
Username: %(username)s
Secret: %(password)s
Action: originate
Channel: SIP/%(local_user)s
WaitTime: 60
CallerId: %(phone_to_dial)s
Exten: %(phone_to_dial)s
Context: outbound-local
Priority: 1
Action: Logoff
"""
def click_to_call(phone_to_dial, username, password, local_user):
pattern = p % {
'phone_to_dial': phone_to_dial,
'username': username,
'password': password,
'local_user': local_user}
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
data = s.recv(1024)
for l in pattern.split('\n'):
print "Sending>", l
s.send(l+'\r\n')
if l == "":
data = s.recv(1024)
print data
data = s.recv(1024)
s.close()
if __name__ == '__main__':
click_to_call(phone_to_dial='555-5555', username='user', password='pass', local_user='101')
my next step is add it as a programs plugin, in which i will enter the extension im i want to make my call from, and also enter (or select from a telephone directory) the number i want to dial.
Note: in order for this script to work, some modifications need to be done to asterisk's manager.conf as in to allow telneting into the server:
Code:
[general]
enabled = yes
;webenabled = yes
port = 5038
[user]
secret = pass
permit = 192.168.1.0/255.255.255.0
read = system,call,log,verbose,command,agent,user,dialplan,originate
write = system,call,log,verbose,command,agent,user,dialplan,originate
again, if anyone has any thoughts on how to make this useful, let me know, maybe we could make something out of this.