I'm currently working on a project 'email to voice call'. Using python i'v extracted the email & converted it into speech and saved in a WAV file. Now using asterisk (I'v installed Asterisk 10.2.1 on my ubuntu 10.10 os) i want to generate call to the cell phone (say 919833000000 india's no.) of the user through my system.
I have written a python code to connect to asterisk manager interface. Also i have configured the sip.conf and extensions.conf files as well as manager.conf. I have registered with voip provider voiceall.com and have a username password of it.
Now when i'm executing the python code, the code is getting executed without any error but nothing is happening. No call is getting generated. Can anyone help me out with this. The python code is as below:
import sys, os, socket, random
# Asterisk Manager connection details
HOST = '127.0.0.1'
PORT = 5038
# Asterisk Manager username and password
USER = 'MYUSERNAME'
SECRET = 'MYPASSWORD'
# Set the name of the SIP trunk to use for outbound calls
TRUNK = 'voiceall'
OUTBOUND = '919833000000'
# Send the call details to the Asteirsk Manager Interface
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
sleep(3)
s.send('Action: login\r\n')
s.send('Username: ' + USER + '\r\n')
s.send('Secret: ' + SECRET + '\r\n\r\n')
sleep(3)
s.send('Action: status\r\n')
data = s.recv(1024)
print data + '\n'
s.send('Events: off\r\n\r\n')
sleep(3)
s.send('Action: originate\r\n')
s.send('Channel: Sip/' + TRUNK + '/' + OUTBOUND + '\r\n')
s.send('WaitTime: 30\r\n')
s.send('CallerId: VOICEALL_USERNAME\r\n')
s.send('Application: playback\r\n')
s.send('Data: /home/Documents/newdemo1' + '\r\n') #newdemo1 is the wave file
s.send('Context: testing\r\n')
s.send('Async: true\r\n')
s.send('Priority: 1\r\n\r\n')
sleep(10)
s.send('Action: Logoff\r\n\r\n')
s.close()
My sip.conf file is as below:
[general]
register => VOICEALL_USERNAME:VOICEALL_PASSWORD@sip.voiceall.net:5038
[voiceall]
canreinvite=no
context=mycontext
host=sip.voiceall.net
secret=VOICEALL_PASSWORD ;your password
type=peer
username=VOICEALL_USERNAME ;your account
disallow=all
allow=ulaw
fromuser=VOICEALL_USERNAME ;your account
trustrpid=yes
sendrpid=yes
insecure=invite
nat=yes
The extensions.conf file is as below:
[mycontext]
include => voiceall-outbound
[voiceall-outbound]
exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@voiceall)
exten => _1NXXNXXXXXX,n,Playback(/home/Documents/demonew1)
exten => _1NXXNXXXXXX,n,Hangup()
exten => _NXXNXXXXXX,1,Dial(SIP/1${EXTEN}@voiceall)
exten => _NXXNXXXXXX,n,Playback(/home/Documents/demonew1)
exten => _NXXNXXXXXX,n,Hangup()
exten => _011.,1,Dial(SIP/${EXTEN}@voiceall)
exten => _011.,n,Playback(/home/Documents/demonew1)
exten => _011.,n,Hangup()
Please help me out, as i am new to asterisk. Any help will be appreciated. Thanks in advance.