AMI command to do a specific test call

Good afternoon. I have something I’m working on - a ZoHo Creator application that can be used to kick off a test call to our techs in the field for an inbound call test.

Ultimately what I want Asterisk/FreePBX to do is:
-Call the external number (give up after 30 seconds)
-Once connected to the external number, route the call to the Echo Test (stop after 2 minutes)

My hope was to have ZoHo send the AMI command to Asterisk, but I don’t know what that command would look like. Meaning, we have multiple outbound trunk groups so naming the SIP channel for outbound isn’t the greatest (I’d rather it use the Outbound Route patterns FreePBX built). Also, in general, I’m not sure what I’d have to submit to AMI to make this all happen.

I toyed with actually making a little dialplan application that did all this, then just use AMI to call that application, but don’t really even now how to do that either (I thought maybe the application would have a variable for the external number, and in the AMI command, the VAR value would be transmitted to define the external number).

Anyone have any thoughts on this, or the best way to achieve it?

My Echo Test extension is *90 and external calling can be processed either as a 10-digit number or 9+<10DigitNumber>.

Also, right after I posted this, i found out my issue was with the context I was using. This command works:
Action: Originate
Channel: SIP/C1a-OUT/
Context: from-internal
Exten: *90
Priority: 1
Callerid: 5138888888
Timeout: 30000
ActionID: ZOHO-Test

But, I still don’t know how to put a max duration on it, nor how to not require naming the outbound SIP trunk (since we have 5 possible outbound trunks).

Thanks.

1 Like

Might be easier for your script to create a .call file and generate the call that way?

https://www.voip-info.org/wiki/view/Asterisk+auto-dial+out

I was thinking if web manager worked, I could actually post a URL to kick it off, but haven’t been able to get that to work as of yet even with me just entering the data manually myself (comes back with 404 Not Found):
http://<SystemAddress>:8088/manager?action=login&username=<TheActualUserName>&secret=<TheActualSecret>
then:
http://<SystemAddress>:8088/manager?action=Originate&Channel=SIP/C1a-OUT/<DestinationNumber>&Context=from-internal&Exten=*90&Priority=1&Callerid=GCIT%20VoiceTest%20%3C5138888888%3E&Timeout=30000&ActionID=ZOHO-Test-%3Crandom%3E

I’m concerned with being able to actually get the call file onto the system, since the Zoho Creator application is on other servers in another data center.

Apparently HTTP access to manager is disabled (even though in the manager_custom.conf I have “webenabled = yes”.

HTTP Server Status:
Prefix: 
Server: Asterisk/13.19.1
Server Enabled and Bound to [::]:8088

HTTPS Server Enabled and Bound to [::]:8089

Enabled URI's:
/httpstatus => Asterisk HTTP General Status
/static/... => Asterisk HTTP Static Delivery
/ari/... => Asterisk RESTful API
/ws => Asterisk HTTP WebSocket

AMI has

https://www.voip-info.org/wiki/view/Asterisk+manager+API

AbsoluteTimeout: (seconds); (this would include ringtime)

to follow your constructed outbound route, you can use :-

SIP/outbound-allroutes/

You can dial out to Local

I tried this:
Action: originate
Channel: SIP/outbound-allroutes/PSTNNumber
Context: from-internal
Exten: *90
Priority: 1
Callerid: GCIT Voice Test <5138888888>
Timeout: 30000
ActionID: ZOHO-Test-<Variable/Generated>
And it said ORIGINATE FAILED

I tried this:
Action: originate
Channel: SIP/local/PSTNNumber
Context: from-internal
Exten: *90
Priority: 1
Callerid: GCIT Voice Test <5138888888>
Timeout: 30000
ActionID: ZOHO-Test-<Variable/Generated>
And also got ORIGINATE FAILED

:frowning:

This is wrong. You want to originate to

local/[email protected]
1 Like

BEAUTIFUL. That worked like a charm. THANK YOU!!!

Now, any idea why I can’t send that via HTTP (Manager isn’t enabled, but I’ve got webenabled=yes in my manager_custom.conf file)?

Enabled URI’s:
/httpstatus => Asterisk HTTP General Status
/static/… => Asterisk HTTP Static Delivery
/ari/… => Asterisk RESTful API
/ws => Asterisk HTTP WebSocket

You must have webenabled in the general section of manager.conf:

[general]
enabled = yes
webenabled = yes

then reload fwconsole r and confirm http mgr status with:

# asterisk -x "manager show settings"

Global Settings:
----------------
  Manager (AMI):             Yes
  Web Manager (AMI/HTTP):    Yes

Since manager.conf has an “includes” for the two other manager-related files, shouldn’t it have picked that up when I added it to manager_custom.conf?

It matters where the include lines are placed in the original file. In this case, manager.conf does not have an include for the [general] section. If it did, it would be called something like manager_general_custom.conf and the include line would be placed after the [general] line not at the end of the file.

Unlike most Asterisk conf files, FreePBX permits users to edit manager.conf so it is simple to just make the changes directly.

Thats cool. Thank you. I assumed it was auto-generated from FPBX, thus would be overwritten with the next Apply.

1 Like

Don’t assume, confirm. The header of manager.conf doesn’t have the typical warning about editing.

True - I was doing the editing through the Config Edit module, which didn’t allow editing of that file. Once I made the edits directly, it took.

Thanks.

1 Like

Is there any way to have the authenticate and originate actions in the same string? I tried assembling it as all one thing, and it didn’t seem to like that. I had to authenticate first, then send the second submission with the originate action.

Thanks.

Since there’s an AMI acknowledgment in between those, I don’t think so. You might be able to do it with a pair of new-lines in the string (simulating a blank line) in the string, but I still think it’s going to end up being two pieces. Try it and see - AMI is a reasonably forgiving protocol.

Sadly, no luck. :frowning:

You have to authenticate (one stanza) before you can do anything else

Action: login
Username: admin
Secret: god

Action: Originate
Channel: SIP/101test
Context: default
Exten: 8135551212
Priority: 1
Callerid: 3125551212
Timeout: 30000
Variable: var1=23|var2=24|var3=25
ActionID: ABC45678901234567890

Don’t forget the empty line after each stanza to commit said stanza

That’s what I was afraid of. I’ve got a 3rd party system that I want to send a command to the system to issue a test call, and it’s sending the two URLs but it’s happening so fast, it’s before the AUTH has been received and I’m not really able to slow it down (that I’ve found yet). It’s also possible the auth is coming from a different IP than the next URL pull (the system is in multiple data centers). So, bummer there…

You would need to have a proxy running on 5038 listening to the 3rd party, then serialize the two before calling AMI on 127.0.0.1:5038, and have ami only bind to localhost. (or change the ports for one or the other)

I see you might be using ami over html, the same thing would apply but you need in your case to proxy 8888 from ethN to localhost and bind the ami/http similarly to localhost only