Custom VBScript Code - Twitter incoming calls (kb4067)
The information in this article applies to:
- SwyxWare all versions
This article describes how to create new status messages (Tweets) on twitter.com on incoming calls.
This can be usefull for example for
- Status messages (like an overflow in call center groups where usually emails would be sent)
- A sort of public call journal for certain numbers
Other articles in this series:
- Custom VBScript Code - Access web pages within a script (kb2650)
- Custom VBScript Code - Call logging into database (kb2218)
- Custom VBScript Code - Call logging into textfile (kb2217)
- Custom VBScript Code - Caller verification in database (kb2219)
- Custom VBScript Code - Check for Bank Holiday (kb2285)
How to setup the script
Download the file kb4067_Twitter.rse via the link at the end of this article. To load the file into the Call Routing Manager (CRM) i.e. the Graphical Script Editor (GSE) do the following:
- Open the Call Routing Manager (CRM).
- Click on New...
- Select Graphical Script Editor (GSE) and click Ok.
- Open the menu Files | Import... im GSE.
- Select the file kb4067_Twitter.rse. The rule will now be loaded and looks like this:
- Save the rule via the menu File | Save.
- Close the GSE.
- Move the rule to the top of the list of rules within the CRM:
- Click on the both parameters in the description field of the rule and enter the username and password belonging to your twitter.com account.
How it works
The Twitter service provides a so called Twitter API. This is a web (HTTP) based interface which can be used (beside others) to add new status messages (Tweets) via a simple HTTP request. Such HTTP requests can be created quite easily from within a call routing script. The script in this articles provides a function TwitterCall which can be called from naerly every place within graphical part of the call routing script. By calling this function the current phone call can be twittered in certain situations, like calls from certain numbers, overflows in call queues, timeouts in call queues.
Own VBScript code (to be more specific: own functions, subroutines, constant definitions and variable declarations) will be placed into the Start Block of a call routing script.
The code being placed here can be called from nearly everywhere within the call routing script (as also from other call routing scripts for the same user as long as the script holding the code is activated). This example script uses the VBScript Code block to call the function.
To make the script a little bit more easy and flexible to use two rule parameters are used to pass username and password from the Call Routing Manager (description field of the rule) into the script without the need for the user to open the GSE.
GSE rule parameters will be defined within the properties of the GSE rule and are available in own defined variables within the call routing script.
The example script calls for every incoming call the TwitterCall function and passes the login information (rule parameters) as parameters. Afterwards the rule will be exited via the Rule skipped exit to force the Call Routing Manager to also start following rules in the list of rules.
This is the VBScript code being stored in the Start block:
If the server is able to resolve the caller name (from the global or private phonebook or a previous running script) this name will be used within the Twitter Tweet, otherwise just the caller's phone number.
Afterwards an HTTP request to Twitter will be executed using the Windows buid-in XMLHTTP COM object.
Using PBXScript.OutputTrace the status message (Tweet) as also the Twitter return code will be written into the server's trace file for failure analysis.
- 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.
- Twitter Sample Script
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.