State for local channel in queue

Hi,

I’m trying to get local channel to work with queue based on this post:
https://community.asterisk.org/t/hint-state-interface-of-public-number-in-local-queue/78863

This is my queue status that shows invalid state. Could someone help with a hint on how to get local channels to work with queues and states?

 Members:
      +223344556677 (local/+223344556677@cust131-dial from Custom:+223344556677) (ringinuse disabled) (realtime) (Invalid) has taken no calls yet

And this is the extension I use for local channel

[cust131-dial]
exten => _X.,1,NoOp(Cust131 Queue localchannel dial ${EXTEN})
    same => n,Set(DEVICE_STATE(Custom:${EXTEN})=INUSE)
    same => n,Dial(PJSIP/test/sip:${EXTEN}@sip.test.com,300,b(add-p-pref^+223344556677^1))
    same => n,Hangup()
    same => h,Set(DEVICE_STATE(Custom:${EXTEN})=NOT_INUSE)

You haven’t initialised it for the first call.

Your from seems invalid, is used to check for agent state, and only valid for sip devices

local/+223344556677@cust131-dial from Custom:+223344556677

Try

queue add member Local/223344556677@cust131-dial/n to queue-name

Check too the dialplan at cust131-dial

_x. only match numbers (0-9) not your +

Missatge de david551 via Asterisk Community <asterisk@discoursemail.com> del dia ds., 14 de nov. 2020 a les 20:59:

Device states aren’t limited to SIP or even to VoIP; see:

The OP needs a state interface, because chan_local only returns invalid or not in use, depending on whether the extension exists

He also needs it because the device is remote to Asterisk, and Asterisk will only know the state of the trunk, not a particular number at the end of that trunk.

Custom states are there for those sort of cases.

Hi,

I seem to be getting in the right direction. I have unknown state now.
Could you give some guidance on how to initialize the state for the first call?

I corrected the extension to cover the + and hangup. Thanks for noticing it!

[cust131-dial]
exten => _+X.,1,NoOp(Cust131 Queue localchannel dial ${EXTEN})
    same => n,Set(DEVICE_STATE(Custom:${EXTEN})=INUSE)
    same => n,Dial(PJSIP/test/sip:${EXTEN}@sip.test.com,300,b(add-p-pref^+223344556677^1))
    same => n,Hangup()
exten => h,1,Set(DEVICE_STATE(Custom:${EXTEN})=NOT_INUSE)


   Members:
      +223344556677 (local/+223344556677@cust131-dial from Custom:+492762975760) (ringinuse disabled) (realtime) (Unknown) has taken no calls yet

That comes down to a question that was asked in the last week about running dialplan at startup, although the answer wasn’t ideal.

Hi David,

do you have a link to that discussion?

Will queue deliver call to a device with an Unknown state? If yes that would be ok for me as then the extension with device state will kick in.

It will deliver to unknown, but that means it will actually try the call, so it is more expensive.