AstDB values

Trying to set the “value” of a “family/key” AstDB entry, to the last external caller number, in a 1.4 asterisk version.
I tried: exten=xxx,1,Set(DB(family/key)=${CALLERID(num)})
, but it doesn’t work (what I get in AstDB is “family/key:”, with a “null” as value.
I also tried: Set(foo=${CALLERID(num)}) and then, Set(DB(family/key)=${foo}), with the same results.
Would someone tell me where the mistake is?. Thanks

Hi

one point to start with, if you are posting code make sure you put it in a “code” box

is an example taken from a live system, are you 110% sure you have no spaces ? or ctrl characters in it

Ian

Sorry Ian. I’m not sure I fully understand your comment.

  • What do you mean by “code” box. May be the Development forum?. I couldn`t find open discussions there. Anywere. If you don’t support code issues in this forum, just let me know and please, accept my apologies. I’m not a seasoned user.
    If this is not the case, I still have those two questions:
  • You mean that the code should work if no spaces or control characters are present on it ?
  • In the code you mention, what’s cidnum ? I don’t recognize it as a system variable, at least in Asterisk 1.4. If it is a user defined one, as I mentioned, I tried it with no success.
    Thanks anyway for your comments.

Look at his post and notice how the example he posted was put in that box. That is a code box, it helps make what your posting stand out and easier to read. When posting a message notice the buttons above the area that you type in. One says code. Click it and it will add two tags in the typing box. Paste your “code” in between those tags.

Are you sure that you have a CALLERID(num) value? How about adding a

exten => 3206,1,NoOp(CallerID is: ${CALLERID(num)}) exten => 3206,n,Set(DB(test/key1)=${CALLERID(num)})

What do you get on your console?

-- Executing [3206@from-sip:1] NoOp("SIP/3211-00000005", "CallerID is: 3211") in new stack -- Executing [3206@from-sip:2] Set("SIP/3211-00000005", "DB(test/key1)=3211") in new stack

Hi Mazzic.
Following your suggestions, I discovered that CALLERID(num) works as espected with inner calls, but not with incomming external PSTN calls.
Going further in detail, if I “Answer” the external calls, then and only then, CALLERID(num) gets the expected value, and can be written in AstDB as expected.
The problem I have now is that I want to get the external callerID value and store it in AstDB for later use, “without answering the line”.
Is there a way to do that?
Thanks.

Hi Mazzic.
To complete my previous replay, the function CALLERID(num), opposit to what I was assuming in the pevious replay, does correctly get the external incomming caller-ID value without answering the call, because you can successfully write it in AstDB issuing the Dialplan code:exten=s,1,Set(LASTCALLER/${CALLERID(num)})=1) but then, the caller-ID gets stored in AstDB as a “key”, not as a “value”, so it can’t be specifically retrieved nor used later on.
If you want to store in AstDB the incomming external PSTN caller-ID, as a “value” and not as a “key”, the only way I’ve found as far is as previous replay, that is, answering the line, passing CALLERID(num) to a channel variable (foo in this example), and finally, writtingSet(DB(LASTCALLER/number)=${foo})(if you try directly:Set(BD(LASCALLER/number)=${CALLERID(num)}you get a “null” value).
So finally. Is there a way you could suggest me, to store this value in AStDB, without Answering the line?. Thanks.

No answers?

Hi What are your lines ? and how is teh callerID deliverd,

For example ISDN IAX and SIP do not require the line to be answered to extract callerid.

Ian

Hi.
The line is PSTN, and the standard is ETS 300-659-1 from ETSI. The PBX is being used in Spain, which as far as I understand, is using the same standard than Germany or France, among other European Comunity Members.
Anyway, I suspect the problem comes from the “data types” supported by the diferent fields of AstDB, since the “Family” and “Key” fields, accept the CALLERID(num) readings in on-hook state, wereas “Value” field doesn’t.
Any feedback on this issue, or any other method to keep track of last calling number, thru AstDB, in Asterisk v 1.4?

Sorry.
What does it mean the blue color and the red star showing up in the icon next to my topic? Thanks

I think it just shows you that you have left a comment in that topic.

Sorry. No answers ? What I´m trying to do seems very basic.
No one knows how to store the lastcaller phone number in AstDB, for incoming PSTN calls when the call is not answered? Thanks.

Hi Yes what you are trying to do is basic and working.

as a test can you try this

[test-pstn]
exten => s,1,Noop(${CALLERID(num)})
exten => s,n,Noop(WE WILL NOW ANSWER THE LINE)
exten => s,n,Answer()
exten => s,n,Noop(${CALLERID(num)})
exten => s,n,Hangup()

and post the verbose output from the call

also what is the card you are using for this line ?

Ian

Did you only want to to this for missed calls or for all calls.

This is assuming you can get the caller ID from the PSTN

if its just for returning missed calls, put the SET() command after the internal dial, otherwise put it before the dial command.

[incomming]
exten => s,1,NoOp(This is a call from ${CALLERID(NUM)})
; record our last call
exten => s,n,SET(DB(usefulstuff/last_call)= ${CALLERID(NUM)}))
; Ring our extensions for 30 seconds
exten => s,n,Dial(SIP/a-bunch-of-phones,30)
; Record our last inbound number we missed
exten => s,n,SET(DB(usefulstuff/last_missed_call)= ${CALLERID(NUM)})
; and send tehm to our voicemail
exten => s,n,Voicemail(100)

And to call back (like they do here in au with a *10#)

[outgoing]
; call back our last mised call
exten => *10#,1,NoOp(Calling back  ${DB(usefulstuff/last_missed_call)})
exten => *10#,n,Answer()
; Read the number first. Allows you to hit a key to 
exten => *10#,n,SayDigits(${DB(usefulstuff/last_missed_call)})
exten => *10#,n,Dial(SIP/sip-trunk/${DB(usefulstuff/last_missed_call)})
exten => *10#,n,HangUp()

;...etc

Bearing in mind that this doesn’t deal with anonymous calls or reading back SIP URIs etc, but it gives you a start.

Hope this is useful for you