AMI Originate simpleAction

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.

You haven’t shown what the actual AMI Originate is or what the variables actually are. You’re most likely telling AMI Originate to do the wrong thing.

I agree that you are missing the line that puts the numbers into the system. However, you should note that originate calls Channel and when that answers it runs the dialplan. As such, the code seems to be doing what it should be doing.

If you want to call the external number first, you should use it in the channel setting, possibly using a local channel.

Note though that many jurisdiction have rules against silent calls, so you must be sure that agent picks up instantly if using this mechanism.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.