How to know the status of my ip phone to redirect on the answerer?

Hi @everyone,

I have a group of ip phones but I do not know when they are used by my agents. I use the BLF Status already to know if they are online or not. But that I want to know is how to identified it in the asterisk syntax for redirect others callers on the answerer after a time when an agent is online. If someone have already do that, could you explain me too.

I try with the ivr, but this is used to for a determine hours where the caller can call our company or others departments of the compnay (Closed/Open hours and others things like that).

Maybe If I use the Queue ? But how ?

Best regard,
Lordaker

As Asterisk only has tools for creating IVRs, but nothing called an IVR, I suspect you are using FreePBX, which is supported at https://community.freepbx.org/

Hi @david551 thank you for your answer. But I use a Asterisk from scratch installation, the version 13.23.0

In that case, I don’t know what you mean by IVR.

I use the IVR for the answerer when someone call at the open/closed hours. Now I search a way to tell at callers when the agent is online for the moment, “Please try again later, our agent is online or left a message after the beep” something like that. And we go to the voicemail after 90 seconds of waiting.

I try this code below but I go to the queue even if the agent is not in line.

exten => ${TEST_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
 same => n,Verbose(Call start time: ${CDR(start)})
 same => n,Set(CDR(calldate)=${CDR(start)})
 same => n,Set(CDR(useragent)=${CALLERID(name)})
 same => n,Set(POSTE_EXT=${CALLERID(num)})
 same => n,Ringing()
 same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
 same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
 same => n,Set(RETURNED_VALUE=${ODBC_LASTCALL(${CALLERID(num)})})
 same => n,MixMonitor(${REC_FILE_NAME},b V(1))
 same => n,GotoIf(Queue(test-queue,t,,,30)?in_queue:out_queue)
 same => n(in_queue),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST})
 same => n,Goto(end)
 same => n(out_queue),Goto(num-to-call)
 same => n(num-to-call),GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled)
 same => n(defaultExt),Dial(PJSIP/114&PJSIP/115,30)
 same => n,Goto(end)
 same => n(lastcalled),Dial(PJSIP/${RETURNED_VALUE},30)
 same => n,VoiceMail(${RETURNED_VALUE}@default)
 same => n,Goto(end)
 same => n(end),Hangup()

Your GotoIf isn’t valid.

If you want to check how many available agents are in your queue you can use something like the QUEUE_MEMBER function

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_QUEUE_MEMBER

Finally, I found a way to know the status of my device with the application ChanIsAvail()

Look my new syntax:

exten => ${TEST_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
 same => n,Verbose(Call start time: ${CDR(start)})
 same => n,Set(CDR(calldate)=${CDR(start)})
 same => n,Set(CDR(useragent)=${CALLERID(name)})
 same => n,Set(POSTE_EXT=${CALLERID(num)})
 same => n,Ringing()
 same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
 same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
 same => n,Set(RETURNED_VALUE=${ODBC_LASTCALL(${CALLERID(num)})})
 same => n,MixMonitor(${REC_FILE_NAME},b V(1))
 same => n,GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled)
 same => n(defaultExt),ChanIsAvail(PJSIP/114&PJSIP/115)
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy|call)
 same => n(busy),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call),Dial(PJSIP/114&PJSIP/115,20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(lastcalled),ChanIsAvail(PJSIP/${RETURNED_VALUE})
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy_cdr|call_cdr)
 same => n(busy_cdr),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call_cdr),Dial(PJSIP/${RETURNED_VALUE},20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(end),Hangup()

But they have a problem I noticed in an other topic. About a endpoint bel who is called in my context from-external. However this endpoint bel does not exist in my pjsip.conf file.

I found why I have a “bel” in my varialble “RETURNED_VALUE”, it is beacause in my column channel of my table cdr I have the value PJSIP/belgium-voip-0000065d something like that. And as I take only the 3 first caracter in this value after “PJSIP/” is return bel. I’m actually debugging that by going in the database and edit the column of channel. Thank you @johnkiniston

This is arrived when I call the phone and I’m directly redirect to the “ivr/answerer_2” in the syntax.

 same => n,GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled)
 same => n(defaultExt),ChanIsAvail(PJSIP/114&PJSIP/115)
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy|call)
 same => n(busy),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call),Dial(PJSIP/114&PJSIP/115,20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(lastcalled),ChanIsAvail(PJSIP/${RETURNED_VALUE})
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy_cdr|call_cdr)
 same => n(busy_cdr),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call_cdr),Dial(PJSIP/${RETURNED_VALUE},20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(end),Hangup()

And also I make this observation, when I call the CID of phone 114 or 115, the application ChanIsAvail() return “0” whatever the status of my device used or not.

Any idea about the chanisavail() application who return alway a zero(0) ?

Now I have in the AVAILSTATUS the value 1.

And I have made a little mistake in syntax

same => n,GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled)
 same => n(defaultExt),ChanIsAvail(PJSIP/114&PJSIP/115)
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy:call) ; here GotoIf($["${AVAILSTATUS}"="3"]?busy|call)
 same => n(busy),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call),Dial(PJSIP/114&PJSIP/115,20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(lastcalled),ChanIsAvail(PJSIP/${RETURNED_VALUE})
 same => n,NoOp(## Status of device : ${AVAILSTATUS} ##)
 same => n,GotoIf($["${AVAILSTATUS}"="3"]?busy_cdr:call_cdr) ;here GotoIf($["${AVAILSTATUS}"="3"]?busy_cdr|call_cdr)
 same => n(busy_cdr),Playback(ivr/ANSWERER_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call_cdr),Dial(PJSIP/${RETURNED_VALUE},20)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(end),Hangup()

I edit my syntax with this one now:

exten => ${TEST_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
 same => n,Verbose(Call start time: ${CDR(start)})
 same => n,Set(CDR(calldate)=${CDR(start)})
 same => n,Set(CDR(useragent)=${CALLERID(name)})
 same => n,Set(POSTE_EXT=${CALLERID(num)})
 same => n,Ringing()
 same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
 same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
 same => n,Set(RETURNED_VALUE=${ODBC_LASTCALL(${CALLERID(num)})})
 same => n,MixMonitor(${REC_FILE_NAME},b V(1))
 same => n,ChanIsAvail(PJSIP/114&PJSIP/115,s)
 same => n,Set(PHONESTATUS=${AVAILSTATUS})
 same => n,Set(PHONEAVAIL=${AVAILORIGCHAN})
 same => n,NoOp(## Status of device is ${PHONESTATUS} ##)
 same => n,GotoIf($["${PHONESTATUS}"="3"]?busy:call)
 same => n(busy),Playback(ivr/REPONDEUR_2_OCCUPE_PLATEAU_VENTE_LOOPING)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end)
 same => n(call),Dial(${AVAILORIGCHAN},20)
 same => n,VoiceMail(${AVAILORIGCHAN}@default,s)
 same => n,Goto(end)
 same => n,Hangup()

And when they check the disponibilty of my extensions 114 and 115 with the application ChanIsAvail() only
the extensions 114 is available not the twice.

exten => ${WEBMASTER_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
 same => n,Verbose(Call start time: ${CDR(start)})
 same => n,Set(CDR(calldate)=${CDR(start)})
 same => n,Set(CDR(useragent)=${CALLERID(name)})
 same => n,Set(POSTE_EXT=${CALLERID(num)})
 same => n,Ringing()
 same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
 same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
 same => n,MixMonitor(${REC_FILE_NAME},b V(1))
 same => n,ChanIsAvail(PJSIP/100,sa)
 same => n,Set(PHONESTATUS=${AVAILSTATUS})
 same => n,Set(PHONEAVAIL=${AVAILORIGCHAN})
 same => n,NoOp(## Status of device is ${PHONESTATUS} ##)
 same => n,GotoIf($["${PHONESTATUS}"="2"]?busy:call)
 same => n(busy),Playback(ivr/REPONDEUR_2)
 same => n,VoiceMail(100@default,sb)
 same => n,Goto(end)
 same => n(call),Dial(${PHONEAVAIL},20)
 same => n,VoiceMail(100@default,su)
 same => n,Goto(end)
 same => n(end),Hangup()

Hello @everyone,

I have the code above but when I have already a call on the CID of extension 100, another call do not ring it or no signal on my ip phone that help me to know who calls me when I was online with an other person before the call go in the answerer. Any idea ?

Show us the output from a call using this dialplan, Are calls falling through to your busy label perhaps?

This is output in the CLI :

localhost*CLI>
  == Setting global variable 'SIPDOMAIN' to Ip Address
    -- Executing [028992018@from-internal:1] NoOp("PJSIP/115-00001d47", "Outgoing Call from "John Doe" <115> to 028992018") in new stack
    -- Executing [028992018@from-internal:2] Verbose("PJSIP/115-00001d47", "Call start time: 2018-10-02 20:06:40") in new stack
Call start time: 2018-10-02 20:06:40
    -- Executing [028992018@from-internal:3] Set("PJSIP/115-00001d47", "CDR(calldate)=2018-10-02 20:06:40") in new stack
    -- Executing [028992018@from-internal:4] Set("PJSIP/115-00001d47", "CDR(useragent)=John Doe") in new stack
    -- Executing [028992018@from-internal:5] Set("PJSIP/115-00001d47", "POSTE=115") in new stack
    -- Executing [028992018@from-internal:6] NoOp("PJSIP/115-00001d47", "SendedCID = 115") in new stack
    -- Executing [028992018@from-internal:7] Set("PJSIP/115-00001d47", "CALLERID(num)=042770677") in new stack
    -- Executing [028992018@from-internal:8] NoOp("PJSIP/115-00001d47", "SendedCID = 042770677") in new stack
    -- Executing [028992018@from-internal:9] Set("PJSIP/115-00001d47", "NOW=2018_10_02_20_06_40") in new stack
    -- Executing [028992018@from-internal:10] System("PJSIP/115-00001d47", "echo "--appel_sortant --- callerid : 042770677 ---- 2018_10_02_20_06_40 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
    -- Executing [028992018@from-internal:11] Set("PJSIP/115-00001d47", "REC_FILE_NAME=OUT_2018_10_02_20_06_40_028992018_115.wav") in new stack
    -- Executing [028992018@from-internal:12] Answer("PJSIP/115-00001d47", "") in new stack
    -- Executing [028992018@from-internal:13] NoOp("PJSIP/115-00001d47", "n° Poste = 115") in new stack
    -- Executing [028992018@from-internal:14] MixMonitor("PJSIP/115-00001d47", "OUT_2018_10_02_20_06_40_028992018_115.wav,b V(1)") in new stack
    -- Executing [028992018@from-internal:15] Goto("PJSIP/115-00001d47", "SetProv") in new stack
    -- Goto (from-internal,028992018,17)
    -- Executing [028992018@from-internal:17] Set("PJSIP/115-00001d47", "PROV2USE=BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:18] NoOp("PJSIP/115-00001d47", "Provider to use : BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:19] GotoIf("PJSIP/115-00001d47", "0?WideVoIP") in new stack
    -- Executing [028992018@from-internal:20] GotoIf("PJSIP/115-00001d47", "0?Selfone") in new stack
    -- Executing [028992018@from-internal:21] GotoIf("PJSIP/115-00001d47", "1?BelgiumVoIP") in new stack
    -- Goto (from-internal,028992018,23)
    -- Executing [028992018@from-internal:23] Set("PJSIP/115-00001d47", "NUM2DIAL=028992018") in new stack
    -- Executing [028992018@from-internal:24] System("PJSIP/115-00001d47", "echo "--BelgiumVoIP  --- callerid : 042770677 ---- 2018_10_02_20_06_40 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
  == Begin MixMonitor Recording PJSIP/115-00001d47
    -- Executing [028992018@from-internal:25] NoOp("PJSIP/115-00001d47", "CD BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:26] Dial("PJSIP/115-00001d47", "PJSIP/028992018@belgium-voip,60") in new stack
    -- Called PJSIP/028992018@belgium-voip
    -- PJSIP/belgium-voip-00001d48 is ringing
    -- PJSIP/belgium-voip-00001d48 is ringing
  == Setting global variable 'SIPDOMAIN' to Ip Address
    -- Executing [028992018@from-external:1] NoOp("PJSIP/belgium-voip-00001d49", "## Incoming Call from "John Doe" <042770677> ##") in new stack
    -- Executing [028992018@from-external:2] Verbose("PJSIP/belgium-voip-00001d49", "Call start time: 2018-10-02 20:06:41") in new stack
Call start time: 2018-10-02 20:06:41
    -- Executing [028992018@from-external:3] Set("PJSIP/belgium-voip-00001d49", "CDR(calldate)=2018-10-02 20:06:41") in new stack
    -- Executing [028992018@from-external:4] Set("PJSIP/belgium-voip-00001d49", "CDR(useragent)=John Doe") in new stack
    -- Executing [028992018@from-external:5] Set("PJSIP/belgium-voip-00001d49", "POSTE_EXT=042770677") in new stack
    -- Executing [028992018@from-external:6] Ringing("PJSIP/belgium-voip-00001d49", "") in new stack
    -- Executing [028992018@from-external:7] System("PJSIP/belgium-voip-00001d49", "echo "--appel_sortant --- callerid : 042770677 ---- 2018/10/02 20:06:41 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
    -- PJSIP/belgium-voip-00001d48 is ringing
    -- PJSIP/belgium-voip-00001d48 is ringing
    -- Executing [028992018@from-external:8] Set("PJSIP/belgium-voip-00001d49", "REC_FILE_NAME=IN__028992018_042770677.wav") in new stack
    -- Executing [028992018@from-external:9] MixMonitor("PJSIP/belgium-voip-00001d49", "IN__028992018_042770677.wav,b V(1)") in new stack
    -- Executing [028992018@from-external:10] ChanIsAvail("PJSIP/belgium-voip-00001d49", "PJSIP/100,sa") in new stack
    -- Executing [028992018@from-external:11] Set("PJSIP/belgium-voip-00001d49", "PHONESTATUS=1") in new stack
    -- Executing [028992018@from-external:12] Set("PJSIP/belgium-voip-00001d49", "PHONEAVAIL=PJSIP/100") in new stack
    -- Executing [028992018@from-external:13] NoOp("PJSIP/belgium-voip-00001d49", "## Status of device is 1 ##") in new stack
    -- Executing [028992018@from-external:14] GotoIf("PJSIP/belgium-voip-00001d49", "0?busy:call") in new stack
    -- Goto (from-external,028992018,18)
    -- Executing [028992018@from-external:18] Dial("PJSIP/belgium-voip-00001d49", "PJSIP/100,20") in new stack
    -- Called PJSIP/100
  == Begin MixMonitor Recording PJSIP/belgium-voip-00001d49
    -- PJSIP/100-00001d4b is ringing
    -- PJSIP/100-00001d4b is ringing
    -- PJSIP/100-00001d4b answered PJSIP/belgium-voip-00001d49
    -- Channel PJSIP/100-00001d4b joined 'simple_bridge' basic-bridge <03c08907-9f38-442e-b6bb-a4caf34b1f22>
    -- Channel PJSIP/belgium-voip-00001d49 joined 'simple_bridge' basic-bridge <03c08907-9f38-442e-b6bb-a4caf34b1f22>
    -- PJSIP/belgium-voip-00001d48 answered PJSIP/115-00001d47
    -- Channel PJSIP/belgium-voip-00001d48 joined 'simple_bridge' basic-bridge <23dad974-2923-4b8d-8a11-6c4c206aac1e>
    -- Channel PJSIP/115-00001d47 joined 'simple_bridge' basic-bridge <23dad974-2923-4b8d-8a11-6c4c206aac1e>
  == Setting global variable 'SIPDOMAIN' to '192.168.0.30'
    -- Executing [028992018@from-internal:1] NoOp("PJSIP/116-00001d4c", "Outgoing Call from "Jane Doe" <116> to 028992018") in new stack
    -- Executing [028992018@from-internal:2] Verbose("PJSIP/116-00001d4c", "Call start time: 2018-10-02 20:06:58") in new stack
Call start time: 2018-10-02 20:06:58
    -- Executing [028992018@from-internal:3] Set("PJSIP/116-00001d4c", "CDR(calldate)=2018-10-02 20:06:58") in new stack
    -- Executing [028992018@from-internal:4] Set("PJSIP/116-00001d4c", "CDR(useragent)=Jane Doe") in new stack
    -- Executing [028992018@from-internal:5] Set("PJSIP/116-00001d4c", "POSTE=116") in new stack
    -- Executing [028992018@from-internal:6] NoOp("PJSIP/116-00001d4c", "SendedCID = 116") in new stack
    -- Executing [028992018@from-internal:7] Set("PJSIP/116-00001d4c", "CALLERID(num)=042770677") in new stack
    -- Executing [028992018@from-internal:8] NoOp("PJSIP/116-00001d4c", "SendedCID = 042770677") in new stack
    -- Executing [028992018@from-internal:9] Set("PJSIP/116-00001d4c", "NOW=2018_10_02_20_06_58") in new stack
    -- Executing [028992018@from-internal:10] System("PJSIP/116-00001d4c", "echo "--appel_sortant --- callerid : 042770677 ---- 2018_10_02_20_06_58 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
    -- Executing [028992018@from-internal:11] Set("PJSIP/116-00001d4c", "REC_FILE_NAME=OUT_2018_10_02_20_06_58_028992018_116.wav") in new stack
    -- Executing [028992018@from-internal:12] Answer("PJSIP/116-00001d4c", "") in new stack
    -- Executing [028992018@from-internal:13] NoOp("PJSIP/116-00001d4c", "n° Poste = 116") in new stack
    -- Executing [028992018@from-internal:14] MixMonitor("PJSIP/116-00001d4c", "OUT_2018_10_02_20_06_58_028992018_116.wav,b V(1)") in new stack
    -- Executing [028992018@from-internal:15] Goto("PJSIP/116-00001d4c", "SetProv") in new stack
    -- Goto (from-internal,028992018,17)
    -- Executing [028992018@from-internal:17] Set("PJSIP/116-00001d4c", "PROV2USE=BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:18] NoOp("PJSIP/116-00001d4c", "Provider to use : BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:19] GotoIf("PJSIP/116-00001d4c", "0?WideVoIP") in new stack
    -- Executing [028992018@from-internal:20] GotoIf("PJSIP/116-00001d4c", "0?Selfone") in new stack
    -- Executing [028992018@from-internal:21] GotoIf("PJSIP/116-00001d4c", "1?BelgiumVoIP") in new stack
    -- Goto (from-internal,028992018,23)
    -- Executing [028992018@from-internal:23] Set("PJSIP/116-00001d4c", "NUM2DIAL=028992018") in new stack
    -- Executing [028992018@from-internal:24] System("PJSIP/116-00001d4c", "echo "--BelgiumVoIP  --- callerid : 042770677 ---- 2018_10_02_20_06_58 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
  == Begin MixMonitor Recording PJSIP/116-00001d4c
    -- Executing [028992018@from-internal:25] NoOp("PJSIP/116-00001d4c", "CD BelgiumVoIP") in new stack
    -- Executing [028992018@from-internal:26] Dial("PJSIP/116-00001d4c", "PJSIP/028992018@belgium-voip,60") in new stack
    -- Called PJSIP/028992018@belgium-voip
    -- PJSIP/belgium-voip-00001d4d is ringing
    -- PJSIP/belgium-voip-00001d4d is ringing
  == Setting global variable 'SIPDOMAIN' to Ip Address
    -- Executing [028992018@from-external:1] NoOp("PJSIP/belgium-voip-00001d4e", "## Incoming Call from "Jane Doe" <042770677> ##") in new stack
    -- Executing [028992018@from-external:2] Verbose("PJSIP/belgium-voip-00001d4e", "Call start time: 2018-10-02 20:06:58") in new stack
Call start time: 2018-10-02 20:06:58
    -- Executing [028992018@from-external:3] Set("PJSIP/belgium-voip-00001d4e", "CDR(calldate)=2018-10-02 20:06:58") in new stack
    -- Executing [028992018@from-external:4] Set("PJSIP/belgium-voip-00001d4e", "CDR(useragent)=Jane Doe") in new stack
    -- Executing [028992018@from-external:5] Set("PJSIP/belgium-voip-00001d4e", "POSTE_EXT=042770677") in new stack
    -- Executing [028992018@from-external:6] Ringing("PJSIP/belgium-voip-00001d4e", "") in new stack
    -- Executing [028992018@from-external:7] System("PJSIP/belgium-voip-00001d4e", "echo "--appel_sortant --- callerid : 042770677 ---- 2018/10/02 20:06:58 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
    -- PJSIP/belgium-voip-00001d4d is ringing
    -- PJSIP/belgium-voip-00001d4d is ringing
    -- Executing [028992018@from-external:8] Set("PJSIP/belgium-voip-00001d4e", "REC_FILE_NAME=IN__028992018_042770677.wav") in new stack
    -- Executing [028992018@from-external:9] MixMonitor("PJSIP/belgium-voip-00001d4e", "IN__028992018_042770677.wav,b V(1)") in new stack
    -- Executing [028992018@from-external:10] ChanIsAvail("PJSIP/belgium-voip-00001d4e", "PJSIP/100,sa") in new stack
    -- Executing [028992018@from-external:11] Set("PJSIP/belgium-voip-00001d4e", "PHONESTATUS=2") in new stack
    -- Executing [028992018@from-external:12] Set("PJSIP/belgium-voip-00001d4e", "PHONEAVAIL=") in new stack
    -- Executing [028992018@from-external:13] NoOp("PJSIP/belgium-voip-00001d4e", "## Status of device is 2 ##") in new stack
    -- Executing [028992018@from-external:14] GotoIf("PJSIP/belgium-voip-00001d4e", "1?busy:call") in new stack
    -- Goto (from-external,028992018,15)
    -- Executing [028992018@from-external:15] Playback("PJSIP/belgium-voip-00001d4e", "ivr/REPONDEUR_2") in new stack
  == Begin MixMonitor Recording PJSIP/belgium-voip-00001d4e
    -- PJSIP/belgium-voip-00001d4d answered PJSIP/116-00001d4c
    -- Channel PJSIP/belgium-voip-00001d4d joined 'simple_bridge' basic-bridge <16a8d367-a318-4ca9-abba-4ce091463eec>
    -- Channel PJSIP/116-00001d4c joined 'simple_bridge' basic-bridge <16a8d367-a318-4ca9-abba-4ce091463eec>
    -- <PJSIP/belgium-voip-00001d4e> Playing 'ivr/REPONDEUR_2.ulaw' (language 'fr')
    -- Channel PJSIP/116-00001d4c left 'simple_bridge' basic-bridge <16a8d367-a318-4ca9-abba-4ce091463eec>
  == Spawn extension (from-internal, 028992018, 26) exited non-zero on 'PJSIP/116-00001d4c'
    -- Channel PJSIP/belgium-voip-00001d4d left 'simple_bridge' basic-bridge <16a8d367-a318-4ca9-abba-4ce091463eec>
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/116-00001d4c
[Oct  2 20:07:09] ERROR[27759]: cdr_odbc.c:176 odbc_log: Unable to retrieve database handle.  CDR failed.
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/belgium-voip-00001d4e
[Oct  2 20:07:10] ERROR[27759]: cdr_odbc.c:176 odbc_log: Unable to retrieve database handle.  CDR failed.
    -- Channel PJSIP/100-00001d4b left 'simple_bridge' basic-bridge <03c08907-9f38-442e-b6bb-a4caf34b1f22>
    -- Channel PJSIP/belgium-voip-00001d49 left 'simple_bridge' basic-bridge <03c08907-9f38-442e-b6bb-a4caf34b1f22>
  == Spawn extension (from-external, 028992018, 18) exited non-zero on 'PJSIP/belgium-voip-00001d49'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/belgium-voip-00001d49
[Oct  2 20:07:21] ERROR[27759]: cdr_odbc.c:176 odbc_log: Unable to retrieve database handle.  CDR failed.
    -- Channel PJSIP/belgium-voip-00001d48 left 'simple_bridge' basic-bridge <23dad974-2923-4b8d-8a11-6c4c206aac1e>
    -- Channel PJSIP/115-00001d47 left 'simple_bridge' basic-bridge <23dad974-2923-4b8d-8a11-6c4c206aac1e>
  == Spawn extension (from-internal, 028992018, 26) exited non-zero on 'PJSIP/115-00001d47'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/115-00001d47
[Oct  2 20:07:22] ERROR[27759]: cdr_odbc.c:176 odbc_log: Unable to retrieve database handle.  CDR failed.

You are sending the call to your ‘busy’ label because PHONESTATUS is 2.

Hi @johnkiniston,

So what status is better to take another call on the ip phone when this one is used (channel is in use)
before he go to the answerer ?

I want to try the status 3, but what is the difference between “channel is in use” and “channel is busy” ?

Best regard,
Lordaker.

In use: the call count is non-zero.

Busy.: the call count is the maximum for the device.

Note that you generally have to set channel driver options for the call counts to be monitored and these to be valid.

Note that you don’t need to explicitly test for BUSY, as calls will fall through to the next dialplan priority if you Dial() a busy device. You need to handle that, anyway, as there can be a race condition in which the status goes to busy between reading the device state and the actual call attempt.

@david551, So This can be my pjsip.conf file, because you say Busy, is when the call count is at the maximum for the device. In my pjsip.conf file I put this parameter for my extension 100:

;==================== EXTENXION 100
[100]
type=endpoint
context=from-internal
subscribe_context=phones-blf
dtmf_mode=rfc4733
disallow=all
allow=ulaw,alaw,gsm,g722,g729
transport=transport-udp
auth=100
aors=100
direct_media=no
mailboxes=100@default
trust_id_outbound=yes
callerid=Arnold <100>

[100]
type=auth
auth_type=userpass
password=***
username=100

[100]
type=aor
max_contacts=1
remove_existing=yes

As you can see max_contacts=1

max_contacts is not relevant to device state.

I can’t find an option that enables busy and in-use device states for PJSIP.

The preferred method of dealing with busy conditions that Asterisk can see is to use group counts, to track the number of users within the dialplan. The only way of detecting a busy state as the result of traffic between the device and something other than Asterisk is to actually dial the device and handle the error.

The busy level is set on the endpoint using the “device_state_busy_at” option. The value is the number of calls at which the device becomes busy.

1 Like
;==================== EXTENXION 100
[100]
type=endpoint
context=from-internal
subscribe_context=phones-blf
dtmf_mode=rfc4733
disallow=all
allow=ulaw,alaw,gsm,g722,g729
transport=transport-udp
auth=100
aors=100
direct_media=no
mailboxes=100@default
trust_id_outbound=yes
callerid=Arnold <100>
device_state_busy_at=2

[100]
type=auth
auth_type=userpass
password=*******
username=100

[100]
type=aor
max_contacts=1
remove_existing=yes

I do this one above. But internal calls as incoming calls, I can’t have a second call to my ip phone. The call go directly to the answerer.