0

As I can see, I can use Asterisk cmd monitor to record the call then use the ControlPlayback to play the recorded file. and the default basename is constructed on the channel name plus a number so How can i playback the last call? for example: I have 3 call, call1, call2, call3 and the channel is 111, so how i can get the name of last call (call3) to playback?

Cœur
  • 37,241
  • 25
  • 195
  • 267
English learner
  • 192
  • 1
  • 9

1 Answers1

0

One easy method would be to use a global variable to store the recorded file name.

[call]
exten => s,1,Answer()
exten => s,n,MixMonitor(${UNIQUEID}.wav)
exten => s,n,Set(GLOBAL(lastcall)=${UNIQUEID})
exten => s,n,Dial(...)

[listen]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Playback(${GLOBAL(lastcall)}.wav)

To read more about the GLOBAL() function:

asterisk*CLI> core show function GLOBAL

  -= Info about function 'GLOBAL' =-

[Synopsis]
Gets or sets the global variable specified.

[Description]
Set or get the value of a global variable specified in <varname>

[Syntax]
GLOBAL(varname)
viktike
  • 717
  • 4
  • 7