How change the CallerID when you make external calls?

Dial(SIP/<endpoint corresponding to desired breakout point>/<destination number>)

As noted, the provider must be able to distinguish between endpoints, and, if they only use IP address, they will not be able to do so.

This syntax is correct for chan_sip, replacing PJSIP by SIP. I’m not certain that it is right for chan_pjsip.

In PJSIP it would be PJSIP/<destination number>@<endpoint>

WaitExten doesn’t work this way. This code will always dial, the presumably invalid number, 300. Also the GotIf is redundant, as the true branch jumps to the same place as it will fall through to on false.

(If WaitExten returns a number, the dialplan will be started over with that number, at priority 1, in the current context.)

Furthermore, I don’t know how chan_pjsip will parse the …/ part of the dialstring, but it is not going to parse any part as a dialplan context.

I think your problems are because you fundamentally do not understand how Asterisk dialplans work; people here assume a basic understanding, and hint in the right direction from that. I think your choices are probably to take a course, or to pay a consultant, although most people would be able to get there just from the documentation.

Certainly my knowledge about Asterisk are limited but actually I’m reading some books on Asterisk ( Asterisk - La téléphonie d’entreprise libre, by Philippe Sultan) who is a french edition, with Asterisk - The Future of Telephony - 2nd Edition). But you can help me to understand some points about it and I think what I want to do, isn’t impossible.

I also watch some webinars Astricon on youtube but Is the basic of Asterisk.

But if I want to tell to dial a number toward an other context with PJSIP ?

I look here bellow but I don’t see or maybe I don’t really understand…

I don’t know what you mean by “other context”.

You dial a phone number using an endpoint. An endpoint defines where the call is sent and the configuration to use.

Yes, If I have two context and I want to Dial a number by going to another context.


exten => 300,1,NoOp(outbound call with Selfone)
 same => n,Playback(enter-ext-of-person)
 same => n,WaitExten(30)
 same => n,Dial(PJSIP/second-context/${EXTEN}@context_provider_in_pjsip.conf)
 same => n,Hangup()

exten => s,1,Dial(PJSIP/${EXTEN}@context_provider_in_pjsip.conf)
 same => Hangup()

You don’t use a PJSIP dial string for that. You do a Goto() to the other context, or you use a Local channel[1] to execute the other dialplan as a channel. PJSIP has no idea about dialplan contexts.


Ok, I will change my syntax with the Goto() and try also a Local channel in my dialplan (extensions.conf).
But, Can I do my goal. It’s possible with Asterisk from scratch ?

Can Asterisk be configured to do such a thing? Yes.

Will your provider correctly match the outgoing call to the right account? That’s up to them.

This is what I want to do:

My first provider Belgium Voip give me two (02) numbers. One for outbound calls and an other one for inbound calls. My second provider Selfone give me four (04) numbers for inbound and outbound calls.
Now I want a way to select the provider that I want to use for my inbound and outbound call. And by this way, for the provider Selfone, select the number with which I would made my outbound and inbound calls.

So If I want to be able to select a number in the four (04) numbers that I have at Selfone via my Ip Phone for outbound/inbound calls. I must to tell to my provider. And they will make some setting in their own server. Else this can’t be work.

I didn’t say that. It depends on how their network is done. When sending a call anywhere they have to identify who you are and what account. If they do this based on username/password authentication then it’ll work fine. If they do it using some other method, then it may not work. Generally though it should work. You have to try to find out.

@jcolp, @david551 Ok. I will try with the Goto() and the Local channel first. After I will comeback to you. And also I will ask some questions to my providers too about that. Thank a lot :slight_smile:, give me a moment…please.

A lot of this comes down to commercial decisions by the provider. In particular, a provider that is selling single number accounts is probably aiming at people who connect directly from IP phones.

This is what I do with Goto()

;======================== Include Context ===========================
include => outgoing-belgium-voip
include => outgoing-selfone-voip
include => international-calls

;========================= Choose your CallerID ========================
exten => 300,1,NoOp(## Outgoing Call from Selfone ##)
 same => n,NoOp(## Your CallerID is : ${CALLERID(all)} for ${EXTEN} ##)
 same => n,Set(CALLERID(num)=028085449)
 same => n,GotoIf(BXL_IN1=${CALLERID(num)}?selfone:end)
 same => n(selfone),Playback(enter-ext-of-person)
 same => n,WaitExten(30)
 same => n,Goto(outgoing-selfone-voip,${EXTEN},1)
 same => n(end),Hangup()

;=================Patterns for Outgoing Calls from Belgium VoIP ===================
exten => _0XXX,1,NoOp(Belgium-Voip : Outbound Call to the ${EXTEN})
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

exten => _0XXXXXXXX,1,NoOp(Belgium-Voip : Outbound Call to the ${EXTEN})
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,NoOp(Belgium-Voip - Outbound Call to the ${EXTEN})
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

;========================= Patterns for Outgoing Calls from Selfone ========================
exten => _0XXX,1,NoOp(Selfone : Outbound Call to the ${EXTEN})
 same => n,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

exten => _0XXXXXXXX,1,NoOp(Selfone : Outbound Call to the ${EXTEN})
 same => n,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,NoOp(Selfone : Outbound Call to the ${EXTEN})
 same => n,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

But I’m alway out with Belgium Voip, :tired_face:, why he don’t go to the context [outgoing-selfone-voip] ?

You haven’t provided the console output to show what is actually happening and executing, without that noone can answer.

There is no extension 300 in outging-selfone, so the goto will always fail.

Again I don’t think you understand what WaitExten does, or how dialplans work. WaitExten sets ${EXTEN} to the value entered and the priority to one. It does not leave the priority unchanged. Even if ${EXTEN} changed without the priority changing, it would no longer match same, so would fail to find any dialplan to execute.

In my CLI Asterisk:

  == Setting global variable 'SIPDOMAIN' to ''
    -- Executing [300@from-internal:1] NoOp("PJSIP/103-00000008", "## Outgoing Call from Selfone ##") in new stack
    -- Executing [300@from-internal:2] NoOp("PJSIP/103-00000008", "## Your CallerID is : "Arnold" <103> for 300 ##") in new stack
    -- Executing [300@from-internal:3] Set("PJSIP/103-00000008", "CALLERID(num)=028085449") in new stack
    -- Executing [300@from-internal:4] GotoIf("PJSIP/103-00000008", "BXL_IN1=028085449?selfone:end") in new stack
    -- Goto (from-internal,300,5)
    -- Executing [300@from-internal:5] Playback("PJSIP/103-00000008", "enter-ext-of-person") in new stack
    -- <PJSIP/103-00000008> Playing 'enter-ext-of-person.ulaw' (language 'fr')
    -- Executing [300@from-internal:6] WaitExten("PJSIP/103-00000008", "30") in new stack
    -- Executing [042680871@from-internal:1] NoOp("PJSIP/103-00000008", "Belgium-Voip : Outbound Call to the 042680871") in new stack
    -- Executing [042680871@from-internal:2] Ringing("PJSIP/103-00000008", "") in new stack
    -- Executing [042680871@from-internal:3] Dial("PJSIP/103-00000008", "PJSIP/042680871@belgium-voip") in new stack
    -- Called PJSIP/042680871@belgium-voip
    -- PJSIP/belgium-voip-00000009 is ringing
    -- PJSIP/belgium-voip-00000009 answered PJSIP/103-00000008
    -- Channel PJSIP/belgium-voip-00000009 joined 'simple_bridge' basic-bridge <f4301a6b-0ca8-4728-bad1-4e1688717c13>
    -- Channel PJSIP/103-00000008 joined 'simple_bridge' basic-bridge <f4301a6b-0ca8-4728-bad1-4e1688717c13>
    -- Channel PJSIP/belgium-voip-00000009 left 'simple_bridge' basic-bridge <f4301a6b-0ca8-4728-bad1-4e1688717c13>
    -- Channel PJSIP/103-00000008 left 'simple_bridge' basic-bridge <f4301a6b-0ca8-4728-bad1-4e1688717c13>
  == Spawn extension (from-internal, 042680871, 3) exited non-zero on 'PJSIP/103-00000008'

As @david551 stated, WaitExten doesn’t work like that.

The application WaitExten() can’t be use to take the number of my correspondant for the Dial() ? Not to call a internal phone in the same company but an other person out of the company like a customer market or other.