HOWTO

Custom VBScript Code - Twitter incoming calls (kb4067)

Le informazioni contenute nel presente articolo riguardano i seguenti prodotti:

  • SwyxWare all versions

[ Riepilogo | Informazioni | Referenze ]


Riepilogo

This article describes how to create new status messages (Tweets) on twitter.com on incoming calls.

Twitter Logo
Twitter Logo
Cliccare per ingrandire...

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:


Informazioni

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:

    Graphical Script Editor
    Graphical Script Editor
    Cliccare per ingrandire...

  • 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:

    Call Routing Manager
    Call Routing Manager
    Cliccare per ingrandire...

  • 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.

Start Block
Start Block
Cliccare per ingrandire...

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.

Insert Script Code Block
Insert Script Code Block
Cliccare per ingrandire...

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.

Rule Properties - Parameters
Rule Properties - Parameters
Cliccare per ingrandire...

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:

 

  1. Function URLescape(ByVal sURL)
  2.     URLescape = sURL
  3.     URLescape = Replace(URLescape, "-", "%2D")
  4.     URLescape = Replace(URLescape, "'", "%27")
  5.     URLescape = Replace(URLescape, """", "%22")
  6. End Function
  7.  
  8.  
  9. Function TwitterCall(ByVal sUser, ByVal sPassword)
  10.     Dim xml
  11.     xml = PBXScript.CreateObject("Microsoft.XMLHTTP")
  12.  
  13.     Dim sStatus
  14.     sStatus = "Just received a call from "
  15.  
  16.     If PBXCall.CallingPartyName <> "" Then
  17.         sStatus = sStatus & PBXCall.CallingPartyName & _
  18.          " (" & PBXCall.CallingPartyNumber & ")"
  19.     Else
  20.         sStatus = sStatus & PBXCall.CallingPartyNumber
  21.     End If
  22.  
  23.     PBXScript.OutputTrace("New Twitter Status: " & sStatus)
  24.  
  25.     xml.Open("POST", "http://" & sUser & ":" & sPassword & _
  26.      "@twitter.com/statuses/update.xml?status=" & _
  27.     URLescape(sStatus), False)
  28.     xml.setRequestHeader("Content-Type", _
  29.      "content=text/html; charset=iso-8859-1")
  30.     xml.Send()
  31.  
  32.     PBXScript.OutputTrace("Twitter Response: " & _
  33.     xml.responseText)
  34.  
  35.     xml = Nothing
  36.  
  37. End Function

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.


Referenze

As far as software supplied or used by us, includes open source elements the additional terms under https://www.swyx.com/open-source apply in addition. An overview which products from the Swyx portfolio include open source elements and which open source license is relevant can be found under https://www.swyx.com/open-source.

Informazioni di altri produttori proposte in questo articolo hanno il compito di appoggiare la ricerca di informazioni tecniche. I contenuti potrebbero essere modificati senza preavviso. Swyx non garantisce per la veridicità dei contenuti di articoli di terzi e declina ogni responsabilità per essi.


Commento

L'articolo è stato utile? Lasci un commento all'articolo



Come possiamo contattarLa se dal Suo commento dovessero nascere altri quesiti?

Indirizzo e-mail Adresse (facoltativo)


Nota

Il campo destinato ai commenti non è ammesso per richieste all'assistenza. Per quesiti inerenti l'assistenza rivolgersi esclusivamente al proprio rivenditore di fiducia o al distributore competente.