Custom VBScript Code - Caller verification in database (kb2219)
The information in this article applies to:
- since SwyxWare v4.00
Since SwyxWare v4.0 it is possible to define own custom scripts with the Graphical Script Editor (GSE). To create scripts using the GSE you have to license the Option Pack - Extended Call Routing.
This articles describes, how to implement a simple Check in a database (e.g. MS Access) if a caller is known.
- Custom VBScript Code - Call logging into textfile (kb2217)
- Custom VBScript Code - Call logging into database (kb2218)
- Custom VBScript Code - Check for Bank Holiday (kb2285)
Further informations about the new features within the Graphical Script Editor can be found in the article:
Installation of the example rule
Download the complete example code usig the link at the end of this article and copy all included files into the
c:\gse_demo To load the CheckCaller.rse file as rule into your Call Routing Manager i.e. Graphical Script Editor please follow these steps:
- Open the Call Routing Manager.
- Click the New... button.
- Select Graphical Script Editor and click on Ok.
- Within the GSE open the File | Import... menu.
Select the CheckCaller.rse. The rule will be imported and your GSE will look like this:
- Save the new rule using the File | Save menu.
- Close the GSE.
Activate the rule by moving it to the right list box of the CRM.
How it works
Custom code can only be added to the Start rule. All consts, variables and functions you'll define here are available all over the script, i.e. can be used in all blocks e.g. the Evaluate block. Please note, that the final script being created by the GSE places the VBScript statement option explicit to the top of the script. This forces all variables to be used within the script to be declared properly.
To check an incoming call in the database, we use the Evaluate block. As comparison we simply state our function KnownCallerId with the caller id of the current caller as parameter.
This function returns True if the caller is known, otherwise False. In the following we have connected the Match exit with a Play Announcement block to play a simple beep.wav. The No Match exit is directly connected to the exit of the script.
This is how the custom code looks like:
After activating this rule a beep will be played if the user with extension 100 calls us, otherwise nothing happens. Note that we exit the script using the Rule skipped block. This will enable us to use other rules after this one within our call routing.
All callrouting scripts, and therefore also your code, runs under the SwyxWare Service Account. Please make sure that this account has the needed priviliges to access the file/database.
This example utilizes an MS Access database. For demonstration purpose this is totally fine, but not for production environments! In production environments you should use real databases, like MS SQL Server, only!
The script in this example does contain no Error Handling. If an error occurs at runtime, e.g. when trying to access a database, this error will not be handled, the script will stop and the call get lost. If you have enabled Server Tracing for SvrScript on level Info3 you will find the original Microsoft Script Engine error message within the server trace file.
To get your own error handling you have to disable the standard error handling by the Script Engine:
This example show the so called DSN-less Connection to the database. Of course it is possible to connect to any database via ODBC as long as an ODBC datasource is configured on the SwyxServer machine. There is just one line of code to change in the script. Instead of
- ADO Connection String Samples
- Custom Scripts in GSE (Examples)
- Swyx Forum - GSE build in functions
This Swyx Forum article documents the GSE build in functions.
- Swyx Forum - Server Script API
This Swyx Forum article documents the SwyxServer Script API.
- Swyx Forum - VBScript functions
This Swyx Forum article documents all VBScript build in functions.
The third-party contact information included in this article is provided to help you find the technical support you need. This contact information is subject to change without notice. Swyx in no way guarantees the accuracy of this third-party contact information nor is responsible for it's content.