Call number and play file

We want to build an application whereas we call an external number and play a file, similar to the command:

originate SIP/Trunk_Name/2345678901 application playback hello-world

whereas Trunk_Name is the name of the external (& outgoing) SIP trunk, 2345678901 the external number to get dialed and hello-world the name of the audio file to be played when the call recipient lifts the handset.

It works fine, however there is no way to add the originator CallerID, e.g. 9999, to record within the CDR as well that the outgoing call was placed by the extention 9999 (belonging to a specific client, for billing/tracking purposes).

I have been searching several fora and Google articles, to no effect.

How can we include the originator’s CalledID within the above command and/or perform the same action operationally (dial out and playback a file)?

After it works using CLI, we plan to integrate this as an AMI call.

Any help would be greatly appreciated!

http://the-asterisk-book.com/1.6/call-file.html

Tried that…

I test with two local SIP accounts, 9999 is the originator and 9998 the recipient whom we want to dial and playback the recorded message. However, it is NOT working, we get @ the logs:

pbx.c:6510 __ast_pbx_run: Channel ‘SIP/9998-00000000’ sent to invalid extension but no invalid handler: context,exten,priority=test-playback-file,9999,1

Any ideas?

Within extensions_override_freepbx.conf:

[test-playback-file]
exten => _XXXX,1,Set(CALLERID(num)=${CallNo}
same => n,SetCDRUserField(${CallNo})
same => n,Verbose(1, Outgoing Caller ID: {$CALLERID(num)})
same => n,Playback(${CallFile})
same => n,Wait(1)
same => n,Hangup()

The .call file has the structure:

Channel: SIP/9998
MaxRetries: 1
RetryTime: 30
WaitTime: 20
Context: test-playback-file
Extension: 9999
Set: CallFile=hello-world
Set: CallNo=9999

Call.file

Channel: SIP/9998
CallerID: “SOME BODY” <654321345>
Application: playback
Data: yourfile

We tried that, as follows:

action: originate
channel: SIP/MyTrunk/00441234567890
application: playback
data: hello-world
MaxRetries: 2
RetryTime: 30
WaitTime: 20
SetCDRUserField: 45642132

Asterisk does dial outbound, however within CDR we want to include a custom value (e.g. an ID of the type 45642132) in order to be able to get return codes and cross-match CDR with application data. We haven’t managed to record such a variable to CDR using for example the SetCDRUserField command (which must be depreciated as well).

Hence,

(a) Is there a way to record within CDR a custom (random) ID string?
(b) Can we add ActionID: (or a similar) parameter to the callfile in order to be able to disseminate call execution responses from our application as they are received from Asterisk?
© Unless the reveiver of the call answers the call, the script will continue redial indefinitely to the outbound number. Moreover, the status recorded in the CDR is not “NOT ANSWERED” if he receiver handset is not lifted, but “BUSY” always. Hence, the values:
MaxRetries: 2
RetryTime: 30
WaitTime: 20
are never respected/recognized by the script.

Our alternative implementation using AMI:

action: originate
channel: SIP/MyTrunk/00441234567890
application: playback
data: hello-world
MaxRetries: 2
RetryTime: 30
WaitTime: 20
actionid: 1234567
exten: 1234

is not operational, as it reports that this extension number is not available/present (although it is present!)

Call files is a very rough alternative to the AMI way. However, if AMI does not support the dial-and-playback-file operation we require, we’ll try the call file way.

Update: We also tried:

Channel: SIP/9999
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: call-file-test
Extension: 9998
Account: 123456789
CallerID: “Test Call Originator” <9998>

where

[call-file-test]
exten => 10,1,Answer()
exten => 10,n,Wait(1)
exten => 10,n,Playback(hello-world)
exten => 10,n,Wait(1)
exten => 10,n,Hangup()

When invoked, we get from asterisk:

pbx.c:6510 __ast_pbx_run: Channel ‘SIP/9999-00000002’ sent to invalid extension but no invalid handler: context,exten,priority=call-file-test,9998,1

Extensions 9999/9998 do exist. Within the CDR, albeit the file did not playback when receiver answered and line was immediately hang up, within the CDR the call is recorded as “ANSWERED”!

For AMI.
.
Variable: CDR(userfield)
Value: 1234567
.
.

for a callfile

Setvar: CDR(userfield)=1234567

The complexity of the problem has grown to the point i would suggest you use AGI

but also

pbx.c:6510 _astpbx_run: Channel ‘SIP/9999-00000002’ sent to invalid extension but no invalid handler: context,exten,priority=call-file-test,9998,1

the only extension you have in call-file-test is 10

try:-

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html