Custom Context - Include context in other context

Hi there,

I’m trying to use custom contexts module , but I don’t know how to include contexts in other contexts that I already created.

Example:

I’ve created two contexts ( with their own dial patterns)
-mobile
-local-calls

And I would like to create a third context to include other contexts.

[billing-dep]
include => mobile
include => local-calls

The main idea is create departaments and define where they can call.

Thanks you.

Use ‘gosub’ (or is it use macro() and stop using gosub() - I get confused) and go to town.

It’s GoSub(). Macro() is deprecated and slated for removal in future releases.

1 Like

In extensions_custom.conf you do:

[from-internal-custom]
include => billing-dep

This will now include the context billing-dep into the from-internal context which in turn means that mobile and local-calls are part of it and all that have access to from-internal have access to those.

Hi Tom,

But what about if I want to create another dept. where they only must to call to local-calls

[it-dep]
include => local-calls

If i add it to “from-internal-custom” they will have access to mobile calls as well

Thansk you.

Every extension uses “from-internal” so you either need to do some checks in your custom dialplan that only allow the proper extensions to use it or you create other “from-internal” contexts (with unique names) to point the users you want to limit calling to.

Look at the end of extensions_additional.conf, the [from-internal-additional] is the actual context that [from-internal] calls on so all the includes in that context are what every user has access to.

I think it will work but it isn’t valid for me at all

I need to define a context for each extension and change it after employee go out depending of running AGI

Example extension 1000 with context bill-dep

[1000]
type=friend
context=bill-dep
secret=secret
defaultuser=1000
canreinvite=no
nat=no
setvar=DEPEXT=1000

[bill-dep]
exten=>_X.,1,NoOP(–Call from Dep ${DEPEXT})
exten=>_X.,n,Set(CDR(userfield)=${DEPEXT})
exten=>_X.,n,AGI(/opt/custom/checkinout${DEPEXT}.php)
exten=>_X.,nGoto(${CONTEXT},${EXTEN},1)

exten=> _.,1,NoOP(–Call from Dep ${DEPEXT})
exten=> _
.,n,Set(CDR(userfield)=${DEPEXT})
exten=> _.,n,AGI(/opt/custom/checkinout${DEPEXT}.php)
exten=> _
.,n,Goto(${CONTEXT},${EXTEN},1)

( after _ there is and asterisk ( * ) and before a dot ( . ) )

[in]
include => local-calls
include => mobile

exten=> i,1,NoOP(–Non allowed call )
exten=> i,n,Playback(invalid)
exten=> i,n,Hangup()

[out]
include => emergency

exten=> i,1,NoOP(–Non allowed call )
exten=> i,n,Playback(invalid)
exten=> i,n,Hangup()

So when they make a call the context [in] or [out] will be send.

*AGIs will be generated by other application.

Thanks you.

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