Channel variables in file for later use

In call files, I’ve noticed I can set channel variables, and it is quite handy. I am wondering if there is a way to pass variables from an existing file outside of an outbound call via call file.

If I had a file that was CALLERID(num).info stored in my /tmp/ folder, is there a way in the dialplan to search for the file based on the incoming callers number matching the file name, then open the matching file, and use the setvar variables inside for that file for that call?

The thought was I could write variables and save them somewhere, then when a caller calls in again, if I could lookup and pull in that file, I could give them different options, based on what happened in previous calls.

Thanks for any insights here.

That’s what the Asterisk database feature is there to provide.

I think you can also make global variables persistent in the database.

Reading and writing files for this is inefficient in both space and processing power.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_DB

1 Like

Thanks David,

I’ve been reading over the material at a high level. To confirm I’m understanding what you’re recommending, in my scenario:

I would write entries in the AstDB using the callers phone number as the family, and things I want to remember about the caller, like if they used an interpreter last call, as a key.

I could then add keys into my dial plan by setting them as variables at the beginning of each inbound route using:
Set(NEEDINTERPRETER=${DB(5555555555/interpreter)}

In this way the phone system can remember what the caller did, maybe a month before, and simplify the workflow accordingly.

Is my understanding correct?

1 Like

Yes. How you use family and key is up to you, and I suspect I would do them the other way round.

1 Like