Initiate External Call using CLI

Hello,

I would like to initiate an external call using the CLI.
A search has shown that the best way for me to do this is via a ‘call file’ as described here:
https://www.voip-info.org/asterisk-auto-dial-out

However, I am not really getting anywhere here.

The call should be triggered from extension 15 and go through the PJSIP trunk.
It does ring on the external number, but I can’t pick up or anything like that.

My call file so far (SIP server from my provider is 'tel.t-online.de'):

Channel: PJSIP/mytrunk_name/sip:[email protected]
Application: Dial

I don’t know how to place the extension and how exactly to dial correctly like in a ‘normal’ SIP client.
The call also looks completely different in the CDR reports when I let it ring (ANSWER instead of NO ANSWER / s[from-pstn] instead of phone number / CallerIDs empty).
See picture (First call: SIP-client / Second call: caller-file):

What am I doing wrong, or what is missing here to make it work like a ‘real’ call from extension 15?
I’m not really familiar with Asterisk, unfortunately.

Thanks for the help - Best regards

There are 4 ways to originate calls.

  1. AMI
  2. ARI
  3. Cli
  4. Callfiles

The “best” way is the one that works best for you…

Most if the website you referenced is outdated, refer to the official Asterisk docs when in doubt :face_with_monocle:

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files

Essentially you’ll want

Channel: local/<ext>@from-internal
Context: from-internal
Extension: 4917XXXXXXXX3
Priority: 1
1 Like

Hello,

thanks for the help.
It almost works … I originally wanted that I do not have to answer the call again on extension 15, but that is automatically called out (to: 4917XXXXXX3).
Is that also possible?

Many greetings

I’m a bit confused, can you perhaps write it the steps that you want to take place?

1 Like

I’m sorry.

For debug purposes I want to initiate a call to an external number (4917XXXXXXXX3) via CLI in the simplest way.
Command > Call to external number > Ringing 2 times > Terminate Call.

I also want to set something like ‘userfield’ so that I can search call in the CDR reports.

It is only about ringing so that no call costs are incurred by the provider.

I don’t believe that the CLI originate supports that, and other versions would be dependent on the called system initiating early media, or a short timeout. Normal originates don’t complete until the call times out or is answered.

The CLI version of originate doesn’t seem to support early media, or timeout, parameters.

You could reverse the originate and use a local channels to a virtual extension that just waits, on the A side, and specify a timeout for the Dial application on the B side.

I’d also note that excessive use of this might be considered a fair usage breach, or trigger special tariffs for customers who make excessive numbers of short or unanswered calls.

1 Like

If you want to use CLI to originate calls, I don’t think it is possible without a custom dialplan.

But with callfiles you should be to do something like:

Channel: local/4917XXXXXX3@from-internal
WaitTime: 10
Account: foo
Application: Playback
Data: goodbye

This will call 4917XXXXXX3 with the CID set on the outbound route, it will ring for 10 seconds (about two rings in the US) and then hang up. If the callee answered prior to 10 seconds they will hear a recording that says “goodbye” and then get disconnected.

This will also set ‘foo’ in the CDR accountcode field.

You can probably try to play with the Setvar: <var=value> field to set a the userfield for CDR.

1 Like

Thank you, this works about as I expected it to:

Channel: local/4917XXXXXX3@from-internal
WaitTime: 10
Account: test-call
Application: Playback
Data: goodbye

Many greetings

Ahh, yeah. I messed up the above example, corrected now.:slight_smile:

1 Like

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