Dialplan and DIALSTATUS clarification

Hello everyone.
given the following test dialplan, if two users are on the phone, and a third user calls, it always rings free. If say user A and user B are on the phone, and user C calls user A asterisk should tell me that it is busy immediately. Am I wrong?

[from-internal]
exten => _5XX,s,Set(NEWEXTEN=+3905773755${EXTEN:1})
exten => _5XX,n,GoTo(dial-direct)
exten => _X.,s,GoTo(invalid-number)

exten => _X.,n(dial-direct),Dial(PJSIP/${NEWEXTEN})
exten => _X.,n,NoOp(DIALSTATUS: ${DIALSTATUS})
exten => _X.,n,Goto(s-${DIALSTATUS},1)
exten => _X.,n,Hangup()

exten => _X.,n(invalid-number),Playback(invalid)
exten => _X.,n,Hangup()

exten => s-BUSY,1,Playback(busy)
exten => _X.,n,Hangup()

The first s should be a 1, otherwise it will use the same priority as the last line for the previous extension.

You haven’t provided details of the destination phone, how that phone is configured, and how the endpoint for the phone is configured, in Asterisk. All of these affect when and/or if a busy condition is detected.

Most SIP phones will allow at least two calls, before the phone, itself, will report busy.

Hi, I found following simple way to achieve result and it works!
Maybe there is a better way but for now it’s working.

[from-internal]
exten => _[03]XXXX.,1,NoOp(Chiamata in uscita da ${CALLERID(num)} a ${EXTEN})
same => n,GoTo(dial-carrier)

exten => _00XXXX.,1,NoOp(Chiamata in uscita da ${CALLERID(num)} a ${EXTEN})
same => n,GoTo(dial-carrier)

exten => _5XX,1,NoOp(Chiamata interna da ${CALLERID(num)} a ${EXTEN})
same => n,Set(NEWEXTEN=0522375${EXTEN})
same => n,Set(TARGET=PJSIP/${NEWEXTEN})
same => n,NoOp(Stato del chiamato: ${DEVICE_STATE(${TARGET})})
same => n,GotoIf($[“${DEVICE_STATE(${TARGET})}” = “BUSY”]?busy:notbusy)

exten => _X.,1,NoOp(Chiamata in uscita da ${CALLERID(num)} a ${EXTEN})
same => n,GoTo(invalid-number)

exten => _X.,n(dial-carrier),Dial(PJSIP/${EXTEN}@${TRUNK})
same => n,Hangup()

exten => _X.,n(invalid-number),Playback(invalid)
same => n,Hangup()

; Se l’endpoint è occupato
exten => _X.,n(busy),NoOp(Endpoint ${NEWEXTEN} è occupato)
same => n,Playback(all-circuits-busy-now)
same => n,Hangup()

; Se l’endpoint non è occupato
exten => _X.,n(notbusy),NoOp(Endpoint ${NEWEXTEN} è disponibile)
same => n,Dial(${TARGET},20)
same => n,Goto(status-${DIALSTATUS})

; Gestione degli stati della chiamata
exten => _X.,n(status-BUSY),NoOp(Chiamata rifiutata - Occupato)
same => n,Playback(all-circuits-busy-now)
same => n,Hangup()

exten => _X.,n(status-NOANSWER),NoOp(Nessuna risposta)
same => n,Playback(no-answer)
same => n,Hangup()

exten => _X.,n(status-CONGESTION),NoOp(Linea congestionata)
same => n,Playback(congestion)
same => n,Hangup()

exten => _X.,n(status-FAILED),NoOp(Chiamata fallita)
same => n,Playback(ss-noservice)
same => n,Hangup()

; Stato di default se nessuno dei precedenti
exten => _X.,n,Hangup()