Good morning! I am a developer whom is new to phone systems, and am curious to know if Asterisk can support my current need for a project.
I am looking to set up a phone system which interacts with my customer database. The workflow I envision looks something like this:
Customers calls my business line -> PBX checks caller ID to obtain their number -> PBX sends number (over some protocol) to external database -> Database checks for that number against existing customers -> IF it finds a match, the database sends (presumably via the same protocol as before) an extension back to the PBX to connect them to their specific service representative. If no match is found, connect them to the next available representative.
In short, I want a dynamic dial plan based on input from an external database. With that, I have a few questions:
1). Is this possible with Asterisk?
2). On a scale of āhelloWorldā to 150 gB AAA video game title, how difficult would this be to implement?
3). What protocols does asterisk support to achieve this?
Thank you in advance for your comments and time! looking forward to learning a new skill!
I think it is not a good idea to call an external database when a call comes in, unless you know how to asynchronously update the display. The problem is, if there is a communication problem or something is wrong with the database, no calls get processed and you canāt wait until an internet connection times out.
If you keep a local database or simply use astdb.sqlite3 and regularly update it, you should be fine. Itās relatively straightforward to implement this.
Look at func_odbc, you can define a custom sql command to lookup callers in your external database.
Iād say this is pretty easy, if you look for āAsterisk the definitive guideā on google you should find the web version of the book and it has a chapter on ODBC.
You can do this using the ODBC functions in the dialplan ālanguageā ā but I wouldnāt.
I would do this by writing an āexternalā program and calling it from the dialplan using the agi() function. This way you are using a ārealā programming language (C, Perl, PHP, Python, etc) and can use real programming language features like a debugger and have better access to error handling.
Using the ODBC functions always looks messy and fragile to me. I like having a nice little black box I can call so my dialplan can be nice an simple like:
[customer-service]
exten = _x.,1, verbose(1,[${EXTEN}@${CONTEXT}!${ANI}])
same = n, agi(lookup-cs-rep)
same = n, goto(representative,${REP-EXTEN},1)
Where lookup-cs-rep would:
Connect to the database.
Lookup the representativeās extension in the database.
Set a channel variable (REP-EXTEN) with the representativeās extension or the extension of the representative queue if the customer does not have an assigned rep.
I work with Microsoft Sql Server via php and AGI. Also, as has already been noted, it is possible to interact by means of odbc (I did not manage to execute stored procedures with the asterisk odbc interface, just queries).
This is incredibly helpful, thank you! I have asterisk running now and have written a script in python that is accessed by AGI. I can confirm that the python is working and can show the new extension using this line