Problem to Solve

Hello guys,

 I am new to asterisk and have a funcionality to implement. 
 In my system, I have some extensions (SIP protocol) and when I dial a specific 

number (supose 100) I need to place a call to the best candidate to answer this call.
If he don´t answer the call, I need to ring the second candidate and if nobody aswer
the call, I send to an operator that will do the job.

 I try to configure a queue and to create the priority order of members, I set a 

penalty to them to put in order. It works.
When I dial 100, the best member is ringed. If he answer the call, everything is ok.
If he reject the call, the next member is ringged and everything is perfect.

 The problem start when the member does nothing (don´t answer and don´t reject 

the call). The queue system try to call that member again… I want that when the member
does not answer the call, the next member can do.

Anyone know haw to configure this.... In the queue conf... In the dial options... 

All suggestions are welcome !

Thanks in advance


Some information:
I am using asterisk 13.18.3~dfsg-1ubuntu4 from regular ubuntu repositories. I am not using a web frontend… I like configuration files :wink:
I am using realtime asterisk. MySQL database, but with ODBC driver to it. Everything how the manual says…

Are you using the linear strategy?

If you don’t actually need to queue calls, you can simply include consecutive Dial’s in the dialplan .

By the way, in Asterisk terminology 100 is the extension, not the caller.

1 Like

Yes, I am using linear strategy.
Sometimes I think that the queue is not the perfect fit for the problem.
I choose queue because I don´t know thru Dialplan, a way to discover if the extension that I plan to call is online…(they are mobile sip clients)… And I don´t want the caller waiting the sucessive delays of calling people that are not online.

Do you know if it´s possible do test the availability of a sip client before route the call to him ?

Thanks in advance.

Dial and linear queues will beheve much the same for offlne SIP servers. You can use the qualify feature to continually test whether a server is reachable and Dial /Queue will skip it without trying to send an INVITE.

1 Like

The qualify option does not work with realtime peers… I am looking for an alternative.

I can´t receive the ${DIALSTATUS} value… Do you know why ?

I try to use in a SIPPhone (1002) ${DEVICE_STATE(SIP/1002)} , but it always return NOT-IN-USE, even though it is offline. How I can discover if the SIPPhone is online and ready or not ?

Do you think that PJSIP can offer a better infrastructure to build my dialplan ?

Thanks in advance.

For DEVICE_STATE to reliably report unusable devices, you need qualify and, preferably, also that the device actively de-register before going away.

I’ve never used ARA. However, looking at some old source code, it looks like you can use qualify with realtime if you are able to enable rtcachefriends.

If you want to have in use/busy/not-inuse, you need to enable the callcounter option.

I will study these insights that you showed me.
I return with the results.

If a endpoint is not registered to your PBX dial will immediately return and your dialplan will execute the next priority.

exten => test,1,Dial(SIP/100,60)
 same => n,Dial(SIP/101,60)

If you were to dial ‘test’ and 100 was not registered the call would immediately dial 101, there would not be a wait of 60 seconds.

1 Like

As I hinted, the problem may be that the device just disappears, without de-registering, and wll still appear registered until its next re-registration become overdue.

1 Like

Hi, I was off for a few days and got back to the problem.
I was able to resolve the issue using PJSIP. (I have compiled the asterisk 16 from scratch and adapt the configuration to PJSIP).
With the PJSIP, call and equipment monitoring functions work best.
My dialplan now checks if an extension is available and only makes the call if it has a chance to be answered. I keep a table in the database, where I have the order of the extensions to be called and created an ODBC function to retrieve the numbers in sequence.
I will try to improve it so that the query in the database is performed only once (using a multirow resultset).

Thank you David551 for your hints. I was going in a wrong way.

My DIALPLAN (development version) is like this

exten => 250,1,Verbose('START')
exten => 250,n,SET(COUNTER=1)
exten => 250,n(AGAIN),Verbose('Counter Value = ${COUNTER}')
exten => 250,n,GotoIf($["${RAMAL}"=""]?ENDCALL)
exten => 250,n,Verbose('Ramal ${RAMAL}')
exten => 250,n,Verbose('Status -> ${DEVICE_STATE(PJSIP/${RAMAL})}')
exten => 250,n,GotoIf($["${DEVICE_STATE(PJSIP/${RAMAL})}"="NOT_INUSE"]?CALL:NEXT)
exten => 250,n(CALL),Dial(PJSIP/${RAMAL},20))
exten => 250,n,Verbose('Call Status -> -${DIALSTATUS}')
exten => 250,n,GotoIf($["${DIALSTATUS}"="ANSWER"]?ENDCALL)
exten => 250,n(NEXT),NoOp('Next Ramal')
exten => 250,n,SET(COUNTER=${INC(COUNTER)})
exten => 250,n,Goto(AGAIN)
exten => 250,n(ENDCALL),HangUp()

You should probably put in a WAIT statement somewhere in your loop unless you want it to test, fail, and then instantly test again.

But the idea is precisely to answer the caller as quickly as possible. If none of the extensions are available to answer the call, it will be redirected to a queue of operators. I never try again one extension that don´t answer the call.
The effort to determine if a mobile extension (sip phone) is available is precisely to prevent me having to call one by one (with timeouts) to see if someone answers.
The queue of operators is not in the dialplan code that I sent.

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