How change the CallerID when you make external calls?

Hi @everyone,

I have 3 providers with 2 numbers by provider. I want to switch between these number by composing a code.
As something like that :slight_smile:

  • 801 to use the first number of my provider A for outbound call

  • 802 to use the second number of my provider A for outbound call

  • 803 to use the first number of my provider B for outbound call

  • 804 to use the second number of my provider B for outbound call

  • 805 to use the first number of my provider C for outbound call

  • 806 to use the second number of my provider C for outbound call

And also I want to add something in Asterisk, who can tell me what provider I use by typing a code too…
Do you have an idea ?

Best regards,
Lordaker

Use ASTDB or global variables to store the current selection and read it out to decide which end point name to use in the Dial string.

Note that many provider will not be able to distinguish between two different registrations from the same IP address.

@david551, so I can’t register in my pjsip.conf, 3 providers in the same time ?
But how can I use the astdb in my case ?

You can register as many providers as you like. Where you may have difficulties is in in getting the provide to accept that you have multiple accounts on one provider. I’m less familiar with PJSIP, but chan_sip can register multiple accounts with a provider. However, if the provider identifies by IP address, they will no t be able to tell the calls you make apart.

Businesses are expected to use one account, supporting multiple calls, not many different accounts.

The extension handler for your provider switching extension would store the identity of the provider selected, possibly keyed by the caller ID. The extension handler for an outgoing call would retrieve that information and insert it into the dial string.

You could do this a number of ways.

If you wanted each endpoint to set a specific caller ID and use a specific provider you could define a context for each endpoint (or endpoint group)


[from-801]
exten => _X.,1,Set(CALLERID(NUM)=5205551212)
 same => n,Dial(PJSIP/${EXTEN}@provider1)

[from-802]
exten => _X.,1,Set(CALLERID(NUM)=5205551234)
 same => n,Dial(PJSIP/${EXTEN}@provider1)

[from-803]
exten => _X.,1,Set(CALLERID(NUM)=5201234567)
 same => n,Dial(PJSIP/${EXTEN}@provider2)
...

You could also define prefixes that your users could dial before a number to set a specific caller ID and provider.


exten => *1X!,1,Set(CALLERID(NUM)=5205551111)
 same => n,Dial(PJSIP/${EXTEN:2}@provider1)

exten => *2X!,1,Set(CALLERID(NUM)=5205552222)
 same => n,Dial(PJSIP/${EXTEN:2}@provider1)

exten => *3X!,1,Set(CALLERID(NUM)=5205553333)
 same => n,Dial(PJSIP/${EXTEN:2}@provider2)

Or as David recommended you could use the ASTDB.

In the OP he says “composing a code”. I read that as meaning that 8xx are codes to switch the provider, not the calling line. Moreover, the way it was written, I assumed that he wanted the changes to be persistent.

@johnkiniston, thank. I’ll try that.
But there’s a long time that I don’t use database. My knowledge in this skill is very low.

You need no real database knowledge to use ASTDB.

Yes persistent, just for a moment until I change the DID. By exemple, If I want to call some peoples in the same region of me, I use the number of my provider A. But If I want to call the french people who live in France by example, I use the number of my provider B by typing some code to my Ip Phone…

Ah, I read it as the 801-806 were his endpoint names.

Time for coffee.

The way I would expect people to do this is to have the dialplan examine the country code in the dialled number and chose the breakout point accordingly.

1 Like

I try this one:

;===================================== Change of DID ===================================
exten => _7701,1,Set(CALLERID(num)=028085449)
 same => n,NoOp(Now you use selfone outbound ${CALLERID(num)})
 same => n,Playback(enter-ext-of-person)
 same => n,WaitExten(30)
 same => n,Dial(PJSIP/${EXTEN}@selfone-provider)
 same => n,Hangup()

Patterns for outbound calls

;================================== Patterns for Outgoing Calls to Belgium ===========================
exten => _0XXX,1,NoOp(CallerID is ${CALLERID(num)} - Appel sortant)
 same => n,GotoIf($[${CALLERID(num)}==${EXTEN}]?BelgiumVoip:SelfOne)
 same => n,Ringing()
 same => n(BelgiumVoip),Dial(PJSIP/${EXTEN}@belgium-voip-provider)
 same => n,Hangup()
 same => n(SelfOne),Dial(PJSIP/${EXTEN}@selfone-provider)
 same => n,Hangup()

exten => _0XXXXXXXX,1,NoOp(CallerID is ${CALLERID(num)} - Appel sortant)
 same => n,GotoIf($[${CALLERID(num)}==${EXTEN}]?BelgiumVoip:SelfOne)
 same => n,Ringing()
 same => n(BelgiumVoip),Dial(PJSIP/${EXTEN}@belgium-voip-provider)
 same => n,Hangup()
 same => n(SelfOne),Dial(PJSIP/${EXTEN}@selfone-provider)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,NoOp(CallerID is ${CALLERID(num)} - Appel sortant)
 same => n,GotoIf($[${CALLERID(num)}==${EXTEN}]?BelgiumVoip:SelfOne)
 same => n,Ringing()
 same => n(BelgiumVoip),Dial(PJSIP/${EXTEN}@belgium-voip-provider)
 same => n,Hangup()
 same => n(SelfOne),Dial(PJSIP/${EXTEN}@selfone-provider)
 same => n,Hangup()

But When I try to call with belgium voip without typing the 7701 I have this message in CLI:

IPBX-Asterisk*CLI> pjsip show registrations

 <Registration/ServerURI..............................>  <Auth..........>  <Status.......>
==========================================================================================

 belgium-voip-provider/sip:voip.belgium-voip.com:5060    belgium-voip-provider-auth  Registered
 selfone-provider/sip:sip.cmrp.net:5060                  selfone-provider-auth  Registered

Objects found: 2

  == Setting global variable 'SIPDOMAIN' to '192.168.40.55'
    -- Executing [042680871@internal-phones:1] NoOp("PJSIP/104-00000020", "CallerID is 104 - Appel sortant") in new stack
    -- Executing [042680871@internal-phones:2] GotoIf("PJSIP/104-00000020", "0?BelgiumVoip:SelfOne") in new stack
    -- Goto (internal-phones,042680871,6)
    -- Executing [042680871@internal-phones:6] Dial("PJSIP/104-00000020", "PJSIP/042680871@selfone-provider") in new stack
    -- Called PJSIP/042680871@selfone-provider
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [042680871@internal-phones:7] Hangup("PJSIP/104-00000020", "") in new stack
  == Spawn extension (internal-phones, 042680871, 7) exited non-zero on 'PJSIP/104-00000020'
IPBX-Asterisk*CLI>

On my softphone X-Lite, he tells me this number no found…

My impression is that you don’t understand what ${CALLERID(num)} does.

@david551 The CALLERID(num) is not like the DID ? It’s return the extension number of my endpoint, I think.

The initial ${EXTEN} would be the DID, or derived from it, if the service provide provides it properly.

@david551 ${EXTEN} I think is the number that I typing on my Ip Phone when I make a call. And the CallerID(num) is the extension number of my Ip Phone.

This is my dialplan for the endpoint 105 in my extensions.conf file:

exten => 105,1,NoOp(## My number DID is : ${EXTEN} ##)
 same => n,NoOp(## My CallerID is : ${CALLERID(num)} ##)
 same => n,Answer()
 same => n,Playback(hello-world)
 same => n,Hangup()

And this is what I have in the CLI Asterisk when I typing “105” on my Ip Phone 104 :

 == Setting global variable 'SIPDOMAIN' to '192.168.40.55'
    -- Executing [105@internal-phones:1] NoOp("PJSIP/104-00000011", "## My number DID is : 105 ##") in new stack
    -- Executing [105@internal-phones:2] NoOp("PJSIP/104-00000011", "## My CallerID is : 104 ##") in new stack
    -- Executing [105@internal-phones:3] Answer("PJSIP/104-00000011", "") in new stack
    -- Executing [105@internal-phones:4] Playback("PJSIP/104-00000011", "hello-world") in new stack
    -- <PJSIP/104-00000011> Playing 'hello-world.ulaw' (language 'fr')
    -- Executing [105@internal-phones:5] Hangup("PJSIP/104-00000011", "") in new stack
  == Spawn extension (internal-phones, 105, 5) exited non-zero on 'PJSIP/104-00000011'

So how can I have my DID ?

DID has no meaning for a call initiated on an internal phone. What do your really mean?

(Part of the problem maybe that the VoIP providers have hijacked the term Direct In Dialling for something that isn’t really direct in dialling, and you may be stretching the term even more, so you need to describe what you mean without using that term.

The key her is that the I in DID stands for In, and you appear to be dealing with an Outbound call.)

1 Like

What I want to say, is that I have 2 providers.
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.

How can I do that ? Did you have a example of that objective ?

You cannot change the “number” or account used for inbound calls! Your provider will have no mechanism to do that.

You can change the provider used for outgoing calls, simply by changing the dialstring to include the right IP address or endpoint name.

You may or may not be able to change the account within a single provider, for an outgoing call, depending on how the provider identifies the account to which the call relates. If they only match on IP address, you are out of luck.

You may or may not be able to change the number used for an outgoing call, depending on whether or not you can either identify the account, or the provider allows you to present a suitable alternative caller ID. In the latter case, you will need to ensure that the dialplan uses the correct caller ID, and you may need to enable the use of Remote-Party-ID or P-Asserted-Identity for the caller ID.

Yes I known, I can change the number for inbound calls giving by the provider. Only if I ask him to do that. But normaly, I may be able to choose the number line with which I want to made my calls. By example:
If I want to use Selfone to make a call, because I have two providers (Selfone and Belgium Voip) registered on my Asterisk from scratch installation.

On selfone, I have 4 numbers lines for inbound/outbound calls. I want to use one of them for make my outbond call. How tell to Asterisk to use the number 028085449 by example who is a number giving by selfone, for make the call ?

I try this one on my dialplan but is out with belgium voip. Look my Dialplan:

[globals]
;incoming number defintion selfone
LIEGE = 042680871                         
BXL_IN1 = 028085449
BXL_IN2 = 028089982                             
BXL_IN3 = 025882060

[from-Internal]
;========================== 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)
 same => n(selfone),Playback(enter-ext-of-person)
 same => n,WaitExten(30)
 same => n,Dial(PJSIP/selfone-voip/${EXTEN}@outgoing-selfone-voip)
 same => n,Hangup()

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

[outgoing-selfone-voip]
exten => _0XXX,1,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

exten => _0XXXXXXXX,1,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,Dial(PJSIP/${EXTEN}@selfone-voip)
 same => n,Hangup()

[outgoing-belgium-voip]
exten => _0XXX,1,NoOp(${EXTEN})
 ;same => n,Set(CALLERID(num)=042771412)
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

exten => _0XXXXXXXX,1,NoOp(${EXTEN})
 ;same => n,Set(CALLERID(num)=042771412)
 same => n,Ringing()
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

exten => _0XXXXXXXXX,1,NoOp(${EXTEN})
 ; same => n,Set(CALLERID(num)=042771412)
 same => n,Ringing()
 same => n,Dial(PJSIP/${EXTEN}@belgium-voip)
 same => n,Hangup()

;====================================== Incoming Calls =================================
[from-belgium-voip]
exten => _028992018,1,NoOp(### Incoming call from outside to 028992018 ###)
 same => n,Ringing()
 same => n,Dial(PJSIP/101,20)
 same => n,Dial(PJSIP/102,20)
 same => n,VoiceMail(101)
 same => n,Hangup()

[from-selfone-voip]
exten = _028085449,1,(## Appel entrant sur les EXT. 106 et 107 ##)
 same => n,Ringing()
 same => n,Dial(PJSIP/101,20&PJSIP/102,20)
 same => n,VoiceMail(101)
 same => n,Hangup()

 exten = _028089982,1,(## Appel entrant sur les EXT. 108 et 109 ##)
 same => n,Ringing()
 same => n,Dial(PJSIP/101,20&PJSIP/102,20)
 same => n,VoiceMail(101)
 same => n,Hangup()

exten = _025882060,1,(## Appel entrant sur les EXT. 110 et 111 ##)
 same => n,Ringing()
 same => n,Dial(PJSIP/101,20&PJSIP/102,20)
 same => n,VoiceMail(101)
 same => n,Hangup()

exten = _042681959,1,(## Appel entrant sur les EXT. 112 et 113 ##)
 same => n,Ringing()
 same => n,Dial(PJSIP/101,20&PJSIP/102,20)
 same => n,VoiceMail(101)
 same => n,Hangup()