Asterisk : originate call doesn't set the CALLERID in the dialplan
Asked Answered
O

3

6

I am using Asterisk PBX to call a softphone, i use thise command : "originate SIP/100 extension 4004" , in the dialplan, I have to get the CALLERID variable, but in this case, it's always empty!

P.S : if i call the extension (4004), from the softphone(100), the CALLERID is set, and I can get it with : ${CALLERID(num)}.

How to get the caller id in the originate case?

Obtuse answered 6/4, 2012 at 15:16 Comment(0)
O
0

the final solution i am using now :

  • i call my extention from a php script (originate SIP/100 extension 777)
  • i write my extension to a text file (file_put_contents)
  • then i read it in the asterisk dial plan, and set this variable as the caller ID Set(CALLERID(num)=${caller_id}

i didn't find another solution.

Obtuse answered 27/4, 2012 at 16:2 Comment(0)
T
11

When you're originating a call, you set the Caller ID yourself. There are two ways of doing this - either in the originate application yourself, or in the dialplan. An example of this is below.

Action: Originate
Channel: local/12345@outgoing
Application: Echo
CallerID: Asterisk <12345>

extensions.conf:

[outgoing]
exten => 12345,1,NoOp()
same => n,Verbose(1, Outgoing Caller ID: {$CALLERID(all)})
same => n,Dial(SIP/${EXTEN})
same => n,Hangup()

or you could do something like:

exten => 12345,1,NoOp()
same => n,Set(CALLERID(num)=54321)
same => n,Set(CALLERID(name)=Asterisk)
same => n,Verbose(1, Outgoing Caller ID: {$CALLERID(all)})
same => n,Dial(SIP/${EXTEN})
same => n,Hangup()

You should see your caller ID set either in the AMI originate or, if you choose to override it in the dialplan, those values.

For more information, see Manager Action Originate and CallerID Function.

Temptress answered 8/4, 2012 at 2:14 Comment(4)
hello thanks for your answer, but i don't see how to use your solution, since the caller id must be dynamic (i call him from a php script wich receive the extention as parameter). anyway, i am using the same script to write the extention to a file, then i read this file from asterisk with an AGI script, this the solution i work with now. exten => 4004,n,AGI(get_caller_id.php) exten => 4004,n,Set(CALLERID(num)=${caller_id}) thanks.Obtuse
The example above was answering your question as to how to set the caller ID on a channel that is created via an AMI originate. I wasn't attempting to write your application for you. If you need to have a dynamic caller ID, simply use dialplan variables instead of the hard coded values illustrated above, and set the variables from your AGI script.Temptress
i didn't say i am using AMI !! i simply call originate from another script. thank you anyway :)Obtuse
Actually, you never said what you were using, nor did you say it wasn't AMI. AMI is what everybody and their dog use to originate calls.Clearheaded
N
3

I know this is way late but if your on Asterisk 1.8 the Originate app just does not allow it normally.

I had asked in the forums before and they said that feature would be added at a later point. So what I did was modify the app_originate.c to allow number and name to be passed.

Here is the one I wrote up last year: https://github.com/cmendes0101/asterisk-originate-callerid

Been in production for over a year and has been working good. Was written for 1.8. It was a easy modification so if your using a different version you can simple diff the changes and make those small changes to your version to make it happen.

Noodle answered 19/2, 2013 at 19:24 Comment(1)
I have the problem too. My asterisk version is 11. I changed the app_originate.c like your code. But it does't set the callerid. Would you please help me.Ebonieebonite
O
0

the final solution i am using now :

  • i call my extention from a php script (originate SIP/100 extension 777)
  • i write my extension to a text file (file_put_contents)
  • then i read it in the asterisk dial plan, and set this variable as the caller ID Set(CALLERID(num)=${caller_id}

i didn't find another solution.

Obtuse answered 27/4, 2012 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.