Hello everyone,
I’m facing an issue with the AMI Originate action in Asterisk — it’s not dialing the correct number. Here’s my setup and the behavior I’m observing:
def call_via_ami(numero: str, extension_caller: str) → dict:
“”"
Lance un appel sortant via Asterisk AMI (action Originate).
“”"
try:
ami_conn = AMIConnexion()
client = ami_conn.get_client()
channel = f"PJSIP/IA_CATARINA/{extension_caller}"
context = “from-internal”
action = SimpleAction(
‘Originate’,
Channel=channel,
Context=context,
Exten=numero,
Priority=1,
CallerID=extension_caller,
Timeout=30000
)
response = client.send_action(action)
final_response = response.get_response()
print(f"Voici la final_response {final_response}")
ami_conn.logoff()
if hasattr(final_response, 'response') and final_response.response == 'Success':
return {"success": True, "message": f"Appel AMI lancé vers {numero}"}
else:
message = final_response.get_header('Message') if hasattr(final_response, 'get_header') else str(final_response)
return {"success": False, "message": f"Erreur AMI : {getattr(final_response, 'response', 'No response')} - {message}"}
except Exception as e:
return {"success": False, "message": f"Exception AMI : {e}"}
Observed Behavior
With AMI Originate (incorrect):
INVITE 006002@IPs → 006002@IP IN CALL
→ My extension ends up calling itself instead of the external number.
With direct call from MicroSIP (correct):
INVITE 006002@IPs → 60033948001636@IPs IN CALL
→ The call goes properly to the external number.
AMI Response
The AMI response is successful:
Response: Success
ActionID: 1
Message: Originate successfully queued
What I’m trying to achieve
I want the AMI Originate action to:
Call the external number (e.g., 60033948001636)
Bridge that call with my extension (006002)
Show the external number on my softphone (MicroSIP), not my own extension
Any help would be greatly appreciated! Thanks in advance.