Setting outbound caller ID

My application is where a user dials into the system, the system dials out to a PSTN number and connects the two callers. I am doing this in an AGI script, the script is pretty simple

Incoming call gets passed to agi,
agi calls SET CALLERID “FName LName” <npanxx####>
then calls DIAL
Waits for DIAL to complete
Logs call information

Problem is, the caller ID isn’t getting set, it shows up as Unknown name/unknown number.

Any idea why caller id information isn’t being set on the outbound call? I’m using Vitelity, I know they support it.

This is my suggestion if possible try this in ur dial plan outbound context to set out call callerid
Then use dial statement

exten => _1XXXXXXXXXX/7000,1,Set(CALLERID(num)=646810xxx)
this is for pertcular extension like 7000 or for all caller u can set
like this

exten => _1XXXXXXXXXX,1,Set(CALLERID(num)=64681xxxxx)
above examples is with 1 prefix. also u can set at fromuser in sip peer config in sip.conf
may be u can use this with some changes that may help u



I cant see why you are using an AGI to do what is a oneliner in the dialplan,

You just need to do it as above and then check it with a Noop


I appreciate your help, but it’s not a one-liner in the dialplan… It routes calls based on the caller-id of the caller, it has mysql database lookups, call logging, and voice recognition and alot more, however I didn’t find it necessary to explain all of that when the question wasn’t should I be doing this in a dialplan, or by using agi, the question was how come when I set the caller ID in agi it’s not being set on the outgoing dial…

Is that all I am supposed to do, call SET CALLERID and then DIAL and it should get picked up, or do I need to specify the caller id somewhere in the dial statement?

BTW-I am trying to set my outbound caller-id to the caller-id of the incoming call… I tried using the ‘o’ option in the dial command but that didn’t seem to work either.

It depends on who is dealing with your call termination. If you have a traditional telco, they might not honor what you put in for the caller id. The IP based provider I use passes along whatever I give them, but the local copper lines always have their assigned numbers in the CID.

You might try a simple extension in your dial plan that sets the CID to something, and calls you back on your cell, just to see if your termination provider is accepting the CID info.

If that works then you know there is something not quite happy in yoru AGI script.


It is always best to explain fully it stops people wasting their time. But it still stands that you have to test that your supplier will let you set caller ID many wont.

To aid debugging you need to add some noops so you can see whats set.


I concurred to this; otherwise, what you will be getting most likely be wild guesses.

Out of the blue today it started working. I didn’t make any code changes or anything. As I said, I already knew Vitelity supported it, I’ve used it on another Asterisk box, but for some reason my AGI app wasn’t able to set it. Thanks for the information though, it was helpful to see how it’s done in the dialplan for another app I am working on.