0

I need to execute AGI scripts when following events occur:

  1. An incoming call (it is simple just call AGI() function).
  2. When a call is "Ringing" (I cannot figure it out!). <-- Problem, how to do this?
  3. When a call is "Answered" (I do it using U(answer^${CALLID}) option in Dial()).
  4. When a call hangs up (I do it using h special extension).

My dialplan looks like this:

[from_origin]
exten => _X.,1,NoOp(${CALLER_USERNAME} from ${CHANNEL(pjsip,remote_addr)})
 same => n,AGI(agi://127.0.0.1/incoming)
 same => n,Dial(${DIALSTR},45,U(answer^${CALLID}))
exten => h,1,AGI(agi://127.0.0.1/hangup,${CDR(uniqueid)})

[answer]
exten => s,1,Set(theCallID=${ARG1})
 same => n,AGI(agi://127.0.0.1/answered)
 same => n,Return()

Look, I have called 3 fast-agi scripts: incoming, answered and hangup. Now I need to call similar script like ringing when the called party is "ringing". How to achieve this ?

Chitholian
  • 432
  • 1
  • 10
  • 19
  • 1
    Have you looked at AMI event listeners? Probably you can't do this in dialplan. https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+ManagerEvent_DialEnd – miken32 Apr 06 '21 at 15:28

1 Answers1

1

Ringing status is status of the channel(chan_pjsip.so) and it not sent outside channel code.

So no, you can't get it in Dial app. Because it can't be get for some channels types and Dial still should work for those types.

For some channels you can get it via AMI in event listening loop in NewState event. But there are no garantee it will be exactly at same time when you got ringing sip message.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerEvent_Newstate

arheops
  • 15,544
  • 1
  • 21
  • 27