I am trying to initiate a call using Python through the AMI. Code I am using to initiate call:
import socket
ami_host = 'localhost'
ami_port = 5038
ami_username = 'user'
ami_password = 'pass'
destination_number = 'dest_nubmber'
caller_id = 'caller_id'
def connect_to_ami():
ami_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ami_socket.connect((ami_host, ami_port))
response = ami_socket.recv(4096).decode('utf-8')
print(response)
ami_socket.send(f'Action: Login\r\nUsername: {ami_username}\r\nSecret: {ami_password}\r\n\r\n'.encode('utf-8'))
response = ami_socket.recv(4096).decode('utf-8')
print(response)
return ami_socket
def make_outgoing_call(destination, caller_id):
ami_socket.send(f'Action: Originate\r\nChannel: SIP/sipus/{destination}\r\nExten: {destination}\r\nContext: from-internal\r\nCallerID: {caller_id}\r\nAsync: true\r\n\r\n'.encode('utf-8'))
response = ami_socket.recv(4096).decode('utf-8')
print(response)
def close_ami_connection():
ami_socket.send('Action: Logoff\r\n\r\n'.encode('utf-8'))
ami_socket.close()
ami_socket = connect_to_ami()
make_outgoing_call(destination_number, caller_id)
close_ami_connection()
The python code runs successfully but I am getting this error in the Asterisk logs:
WARNING[3907] channel.c: No channel type registered for 'SIP'