Custom context in multi tenant

can I use the same custom context in multi tenant ?

example : my context is in this file and it works with main “vitalpbx” tenant, can I call this in tenant 2 ? what I noticed everything works, however when I use destination in context it is disconnecting the call.

MOD Edit: - It is broken under multi tenant, see conversation below

I think you can share the custom context add-on with other tenants allowing the module in the profile of the tenant users.

this context works fine from the main tenant, however when I use it in the tenant and desitnation is T2100 (tenant extension), I am getting the following error

;Send email
exten=> _.,n,Noop(checking the callerid ${CALLERID(num)})
same=>n,TrySystem(echo "Incoming  Call - From: ${fname} ${lname} ${CALLERID(number)} received at ${STRFTIME(${EPOCH},,%l:%M:%S %p %Z on %A %B %e)}" | mail -s "Phone - Incoming Call to  ${EXTEN}" -r hello@example.net)
 same=>n,Goto(${ARG1},${ARG2},${ARG3})

cc

-- Executing [102@T3_cos-all-post:2] NoOp("SIP/T2101-00000000", "Custom Application: email-notify-CT") in new stack
    -- Executing [102@T3_cos-all-post:3] Goto("SIP/T2101-00000000", "custom-contexts,cc-30,1") in new stack
    -- Goto (custom-contexts,cc-30,1)
021-10-24 02:49:03] WARNING[11404][C-00000001]: pbx.c:4510 __ast_pbx_run: Channel 'SIP/T2101-00000000' sent to invalid extension but no invalid handler: context,exten,priority=custom-contexts,cc-30,1

Why do you use extension “hello”? Usually it is “s”. Don’t know if this will fix your problem.

Did you allow the Custom Context Module on the other Tenant as miguel advised?

same issue wiht using “s”

tenant

custom context is allowed in tenant administration

I am using community release with 1 tenant ? will that be the issue ? no having tenanting license ?

I did a quick test, create ext 100 in the vitalpbx main tenant and dial the context from the tenant, call is going to main tenant ext 100

is there anything else required in the script to define the tenant ?

All these custom context do not get created in Asterisk when you submit them under the tenant. It’s a known bug.

Do you know of a fix or workaround?

IIRC, if you go back to the main tenant and resubmit. But I may be wrong on that… I’m moving this post to #reporting-an-issue and renaming the subject so it can be fixed.

1 Like

Is there any workaround until it is fixed ?

This bug is stopping us to add a tenant, could someone please guide me if there is any workaround to make this work from the tenant?

The workaround would probably be to manually create rh the dialplan.

Would you be able to share an example to create manual dialpla?

Create one under the main tenant and follow that.

This is exactly what I am doing, but when I terminate the call , it goes to the main tenant ext, doesn’t transfer to tenant extension

You will obviously have to send it to the tenant’s context.

Please post an example.

All added in sub tenant (T5), dialed 9001 from extension 51001, call is being disconnected

image
image

Context :

[email-notify-DM]
exten=> _.,1,Set(user=admin)
same=>n,Set(Answer=${CURL(https://example.com/admin/client_data_received?client_id="${CALLERID(number)}"&token=adFki1234861252235fgh1))
same=>n,Goto(${ARG1},${ARG2},${ARG3})

Logs

[2021-11-19 02:06:14] NOTICE[9731]: app_queue.c:9162 reload_queue_rules: No queuerules.conf file found, queues will not follow penalty rules
    -- Executing [9001@T5_cos-all:1] NoOp("PJSIP/T5_51001-0000003c", "More than on digit pattern") in new stack
    -- Executing [9001@T5_cos-all:2] Gosub("PJSIP/T5_51001-0000003c", "s,1(9001)") in new stack
    -- Executing [s@T5_cos-all:1] Set("PJSIP/T5_51001-0000003c", "EXTENSION=9001") in new stack
    -- Executing [s@T5_cos-all:2] NoOp("PJSIP/T5_51001-0000003c", "Dialing 9001 from 51001") in new stack
    -- Executing [s@T5_cos-all:3] Gosub("PJSIP/T5_51001-0000003c", "sub-set-global-vars,s,1(5414c1540305ca71,9001,parking-5)") in new stack
    -- Executing [s@sub-set-global-vars:1] NoOp("PJSIP/T5_51001-0000003c", "Setting Global Vars") in new stack
    -- Executing [s@sub-set-global-vars:2] Set("PJSIP/T5_51001-0000003c", "TENANT_PATH=5414c1540305ca71") in new stack
    -- Executing [s@sub-set-global-vars:3] Set("PJSIP/T5_51001-0000003c", "PREFIX=T5_") in new stack
    -- Executing [s@sub-set-global-vars:4] Set("PJSIP/T5_51001-0000003c", "__PICKUPMARK=T5_9001") in new stack
    -- Executing [s@sub-set-global-vars:5] Set("PJSIP/T5_51001-0000003c", "__PARKINGLOT=parking-5") in new stack
    -- Executing [s@sub-set-global-vars:6] Set("PJSIP/T5_51001-0000003c", "__DYNAMIC_FEATURES=custom-features") in new stack
    -- Executing [s@sub-set-global-vars:7] Set("PJSIP/T5_51001-0000003c", "ICALL=no") in new stack
    -- Executing [s@sub-set-global-vars:8] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:4] Gosub("PJSIP/T5_51001-0000003c", "sub-set-call-vars,s,1(5414c1540305ca71,9001,5,T5_cos-all,T5_ARS-all)") in new stack
    -- Executing [s@sub-set-call-vars:1] NoOp("PJSIP/T5_51001-0000003c", "Setting Call Vars") in new stack
    -- Executing [s@sub-set-call-vars:2] Set("PJSIP/T5_51001-0000003c", "_TENANT=5414c1540305ca71") in new stack
    -- Executing [s@sub-set-call-vars:3] Set("PJSIP/T5_51001-0000003c", "_CALL_DESTINATION=9001") in new stack
    -- Executing [s@sub-set-call-vars:4] Set("PJSIP/T5_51001-0000003c", "_COS_ID=5") in new stack
    -- Executing [s@sub-set-call-vars:5] Set("PJSIP/T5_51001-0000003c", "_COS_NAME=T5_cos-all") in new stack
    -- Executing [s@sub-set-call-vars:6] Set("PJSIP/T5_51001-0000003c", "__TRANSFER_CONTEXT=T5_cos-all") in new stack
    -- Executing [s@sub-set-call-vars:7] Set("PJSIP/T5_51001-0000003c", "_ARS=T5_ARS-all") in new stack
    -- Executing [s@sub-set-call-vars:8] Set("PJSIP/T5_51001-0000003c", "CDR(tenant)=spectrum") in new stack
    -- Executing [s@sub-set-call-vars:9] Set("PJSIP/T5_51001-0000003c", "CDR(destination)=9001") in new stack
    -- Executing [s@sub-set-call-vars:10] Set("PJSIP/T5_51001-0000003c", "CDR(trunk)=") in new stack
    -- Executing [s@sub-set-call-vars:11] Set("PJSIP/T5_51001-0000003c", "CDR(did)=") in new stack
    -- Executing [s@sub-set-call-vars:12] Set("PJSIP/T5_51001-0000003c", "__CALLID=1637283983.144") in new stack
    -- Executing [s@sub-set-call-vars:13] ExecIf("PJSIP/T5_51001-0000003c", "0?Set(CHANNEL(language)=)") in new stack
    -- Executing [s@sub-set-call-vars:14] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:5] Gosub("PJSIP/T5_51001-0000003c", "sub-construct-cid,s,1") in new stack
    -- Executing [s@sub-construct-cid:1] NoOp("PJSIP/T5_51001-0000003c", "Building CID") in new stack
    -- Executing [s@sub-construct-cid:2] Set("PJSIP/T5_51001-0000003c", "_CALL_SOURCE=51001") in new stack
    -- Executing [s@sub-construct-cid:3] Set("PJSIP/T5_51001-0000003c", "_CS=51001") in new stack
    -- Executing [s@sub-construct-cid:4] GotoIf("PJSIP/T5_51001-0000003c", "0?return") in new stack
    -- Executing [s@sub-construct-cid:5] Gosub("PJSIP/T5_51001-0000003c", "sub-get-device-tree,s,1") in new stack
    -- Executing [s@sub-get-device-tree:1] NoOp("PJSIP/T5_51001-0000003c", "Configuring Device Tree") in new stack
    -- Executing [s@sub-get-device-tree:2] Set("PJSIP/T5_51001-0000003c", "DEV_TECHNOLOGY=PJSIP") in new stack
    -- Executing [s@sub-get-device-tree:3] GosubIf("PJSIP/T5_51001-0000003c", "0?s-local,1") in new stack
    -- Executing [s@sub-get-device-tree:4] GotoIf("PJSIP/T5_51001-0000003c", "0?return") in new stack
    -- Executing [s@sub-get-device-tree:5] GotoIf("PJSIP/T5_51001-0000003c", "1?pjsip") in new stack
    -- Goto (sub-get-device-tree,s,9)
    -- Executing [s@sub-get-device-tree:9] NoOp("PJSIP/T5_51001-0000003c", "A PJSIP") in new stack
    -- Executing [s@sub-get-device-tree:10] Set("PJSIP/T5_51001-0000003c", "DEV_USER=T5_51001") in new stack
    -- Executing [s@sub-get-device-tree:11] Goto("PJSIP/T5_51001-0000003c", "build_interface") in new stack
    -- Goto (sub-get-device-tree,s,13)
    -- Executing [s@sub-get-device-tree:13] Set("PJSIP/T5_51001-0000003c", "_INTERFACE=PJSIP/T5_51001") in new stack
    -- Executing [s@sub-get-device-tree:14] Set("PJSIP/T5_51001-0000003c", "DEV_TREE=devices/PJSIP/T5_51001") in new stack
    -- Executing [s@sub-get-device-tree:15] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@sub-construct-cid:6] GotoIf("PJSIP/T5_51001-0000003c", "0?return") in new stack
    -- Executing [s@sub-construct-cid:7] Set("PJSIP/T5_51001-0000003c", "_CALL_SOURCE=51001") in new stack
    -- Executing [s@sub-construct-cid:8] Set("PJSIP/T5_51001-0000003c", "_CS=51001") in new stack
    -- Executing [s@sub-construct-cid:9] ExecIf("PJSIP/T5_51001-0000003c", "1?Set(CALLERID(all)="Test 51001" <51001>)") in new stack
    -- Executing [s@sub-construct-cid:10] Set("PJSIP/T5_51001-0000003c", "_CID_CONSTRUCTED=yes") in new stack
    -- Executing [s@sub-construct-cid:11] NoOp("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@sub-construct-cid:12] Set("PJSIP/T5_51001-0000003c", "CDR(source)=51001") in new stack
    -- Executing [s@sub-construct-cid:13] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:6] Gosub("PJSIP/T5_51001-0000003c", "T5_set-global-tenant-vars,s,1") in new stack
    -- Executing [s@T5_set-global-tenant-vars:1] NoOp("PJSIP/T5_51001-0000003c", "Setting Global Vars for spectrum Tenant") in new stack
    -- Executing [s@T5_set-global-tenant-vars:2] Set("PJSIP/T5_51001-0000003c", "__TENANT_PATH=5414c1540305ca71") in new stack
    -- Executing [s@T5_set-global-tenant-vars:3] Set("PJSIP/T5_51001-0000003c", "__TENANT_PREFIX=T5_") in new stack
    -- Executing [s@T5_set-global-tenant-vars:4] Set("PJSIP/T5_51001-0000003c", "__QUEUE_AGENTS_CONTEXT=T5_queue-call-to-agents") in new stack
    -- Executing [s@T5_set-global-tenant-vars:5] Set("PJSIP/T5_51001-0000003c", "__FOLLOWME_CONTEXT=T5_ext-followme") in new stack
    -- Executing [s@T5_set-global-tenant-vars:6] Set("PJSIP/T5_51001-0000003c", "__HINTS_CONTEXT=T5_extension-hints") in new stack
    -- Executing [s@T5_set-global-tenant-vars:7] Set("PJSIP/T5_51001-0000003c", "__DEFAULT_COS=T5_cos-all") in new stack
    -- Executing [s@T5_set-global-tenant-vars:8] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:7] GotoIf("PJSIP/T5_51001-0000003c", "0?local-dialing") in new stack
    -- Executing [s@T5_cos-all:8] NoOp("PJSIP/T5_51001-0000003c", "Check if is an Emergency Call") in new stack
    -- Executing [s@T5_cos-all:9] GotoIf("PJSIP/T5_51001-0000003c", "0?T5_emergency-calls,9001,1") in new stack
    -- Executing [s@T5_cos-all:10] Gosub("PJSIP/T5_51001-0000003c", "sub-lockphone-check,s,1") in new stack
    -- Executing [s@sub-lockphone-check:1] NoOp("PJSIP/T5_51001-0000003c", "SUB: LOCK PHONE CHECK") in new stack
    -- Executing [s@sub-lockphone-check:2] GotoIf("PJSIP/T5_51001-0000003c", "0?unlock") in new stack
    -- Executing [s@sub-lockphone-check:3] GotoIf("PJSIP/T5_51001-0000003c", "0?unlock") in new stack
    -- Executing [s@sub-lockphone-check:4] GotoIf("PJSIP/T5_51001-0000003c", "0?unlock") in new stack
    -- Executing [s@sub-lockphone-check:5] GotoIf("PJSIP/T5_51001-0000003c", "0?unlock") in new stack
    -- Executing [s@sub-lockphone-check:6] GotoIf("PJSIP/T5_51001-0000003c", "0?:unlock") in new stack
    -- Goto (sub-lockphone-check,s,12)
    -- Executing [s@sub-lockphone-check:12] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:11] Gosub("PJSIP/T5_51001-0000003c", "sub-local-dialing,s,1") in new stack
    -- Executing [s@sub-local-dialing:1] NoOp("PJSIP/T5_51001-0000003c", "Trying to determine if is a local extension") in new stack
    -- Executing [s@sub-local-dialing:2] GotoIf("PJSIP/T5_51001-0000003c", "0?:return") in new stack
    -- Goto (sub-local-dialing,s,5)
    -- Executing [s@sub-local-dialing:5] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [s@T5_cos-all:12] GotoIf("PJSIP/T5_51001-0000003c", "0?end-call") in new stack
    -- Executing [s@T5_cos-all:13] Set("PJSIP/T5_51001-0000003c", "OUTBOUND_PROFILE=") in new stack
    -- Executing [s@T5_cos-all:14] GotoIf("PJSIP/T5_51001-0000003c", "1?post-dialing") in new stack
    -- Goto (T5_cos-all,s,16)
    -- Executing [s@T5_cos-all:16] Goto("PJSIP/T5_51001-0000003c", "T5_cos-all-post,9001,1") in new stack
    -- Goto (T5_cos-all-post,9001,1)
    -- Executing [9001@T5_cos-all-post:1] Gosub("PJSIP/T5_51001-0000003c", "sub-set-call-vars,app-incoming,1") in new stack
    -- Executing [app-incoming@sub-set-call-vars:1] NoOp("PJSIP/T5_51001-0000003c", "Incoming Call App CDR") in new stack
    -- Executing [app-incoming@sub-set-call-vars:2] GotoIf("PJSIP/T5_51001-0000003c", "0?:return") in new stack
    -- Goto (sub-set-call-vars,app-incoming,6)
    -- Executing [app-incoming@sub-set-call-vars:6] Return("PJSIP/T5_51001-0000003c", "") in new stack
    -- Executing [9001@T5_cos-all-post:2] NoOp("PJSIP/T5_51001-0000003c", "Custom Application: test") in new stack
    -- Executing [9001@T5_cos-all-post:3] Goto("PJSIP/T5_51001-0000003c", "custom-contexts,cc-7,1") in new stack
    -- Goto (custom-contexts,cc-7,1)
[2021-11-19 02:06:23] WARNING[9765][C-0000002a]: pbx.c:4510 __ast_pbx_run: Channel 'PJSIP/T5_51001-0000003c' sent to invalid extension but no invalid handler: context,exten,priority=custom-contexts,cc-7,1

Add to your custom conf file

[custom-contexts](+)

exten => cc-7,1,Noop()
 same => n,Gosub(email-notify-DM1,s,1(T5_cos-all,9001,1))

Thanks, I tried this, but script is looping forever.

[custom-contexts](+)

exten => cc-7,1,Noop()
 same => n,Gosub(email-notify-DM1,s,1(T5_cos-all,9001,1))

[email-notify-DM1]
exten=> _.,1,Set(user=admin)
same=>n,Set(Answer=${CURL(https://example.com/admin/client_data_received?client_id="${CALLERID(number)}"&token=adFki1234861252235fgh1))
same=>n,Goto(${ARG1},${ARG2},${ARG3})

image

Sorry, change the destination to 9003, the queue extension.