Same user with two contexts for Sip and extension

I have 2 different type of senarion one an passing calls from user to user another pass the call to ivr
Can i used Same user with two contexts for same Sip and extension
below i give the scenario . if any one help me i will be kind


sip.conf

[general]
context=from-sip
context=from-user
allowguest=yes
autocreatepeers=yes
udpbindaddr=0.0.0.0
bindport=5060
disallow=all
allow=g729
allow=g723
tcpenable=yes
tcpbindaddr=0.0.0.0
dtmfmode=rfc2833
relaxdtmf=yes
srvlookup=yes
transport=udp,tcp

#include sip_additional.conf


sip_additional.conf

[GW-1]
type=friend
host=192.168.101.4
port=5060
nat=yes
context=from-sip
context=from-user
qualify=yes
disallow=all
allow=g723.1
allow=g729
insecure=invite,port
canreinvite=no


extension.conf

[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
[globals]

[from-sip]

exten => _X.,1,NoOp()
exten => _X.,n,Set(STRATEGY=RANDOM)

exten => _X.,n,Dial(SIP/${IAXVAR(route)})
exten => _X.,n,Dial(SIP/${IAXVAR(route)})

[from-user]

exten => _4.,1,NoOp()
exten => _4.,n,Set(STRATEGY=RANDOM)

exten => _4.,n,Dial(SIP/${IAXVAR(route)})
exten => _4.,n,Dial(SIP/${IAXVAR(route)})

You can include one context from the other, but you can only have one context for each peer.

Unless you really know what you are doing, change allowguest to no.

i have 2 differents group for general calls and ivr calls
i like to pass both call using same sip user so my question can i used 2 context,

sip_additional.conf
[GW-1]
type=friend
host=192.168.101.4
port=5060
nat=yes
context=from-sip
context=from-user
qualify=yes
disallow=all
allow=g723.1
allow=g729
insecure=invite,port
canreinvite=no
extension.conf

[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
[globals]

[from-sip]

exten => _X.,1,NoOp()
exten => _X.,n,Set(STRATEGY=RANDOM)

exten => _X.,n,Dial(SIP/${IAXVAR(route)})
exten => _X.,n,Dial(SIP/${IAXVAR(route)})

[from-user]

exten => _4.,1,NoOp()
exten => _4.,n,Set(STRATEGY=RANDOM)

exten => _4.,n,Dial(SIP/${IAXVAR(route)})
exten => _4.,n,Dial(SIP/${IAXVAR(route)})

I’ve already answered that. The answer is “no”. In your example, GW-1 will be in from_user and only from_user.

I also said that you could include from_user within from_sip (see the sample configuration file that comes with the standard installation of Asterisk, for examples.