Author Topic: OCS, SCXML and JavaScript  (Read 4480 times)

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
OCS, SCXML and JavaScript
« on: August 27, 2014, 09:41:18 PM »
Hello,

We haven't used SCXML very much in OCS, but have played around with it for POC purposes.

In the SCXML samples provided with OCS, I have noticed what seems to be some JavaScript functions embedded in <script></script> tags as you might see in HTML source code.  OCS Guides do make vague reference to JavaScript in SCXML files.

I am wondering if anyone has attempted to use the JavaScript object XmlHttpRequest from within an SCXML treatment.

Here is my reason for asking.  I would like to enable pre dial validation in OCS for a campaign.  I want the pre dial validation to do 2 things:
1. Set CPN digits dynamically based on some data attached to the individual record (there is a nice OCS SCXML sample on how this is done, works nicely for us)
2. Consume an endpoint and receive HTTP 200 or HTTP 409 indicating whether or not the record is still eligible to be dialed (explained in OCS deployment guide)

I see that accomplishing these 2 items is possible, but maybe not at the same time.

For example to accomplish item 1:
Set pre-dial-validation to true
set validation-uri to URI of my SCXML file that will set CPN digits for that outbound record

To accomplish item 2:
Set pre-dial-validation to true
set validation-uri to URI of web service endpoing that returns HTTP 200 if it is okay to call record or HTTP 409 if it is not okay to call record with a JSON payload (OCS deployment guide explains this well)

My trouble is, how do I accomplish both at the same time only specifying 1 validation-uri?  I asked specifically about XmlHttpRequest JavaScript object in SCXML because perhaps it is possible for me to consume an endpoint within the SCXML script.

Any thoughts are appreciated.  I am actively testing and will follow up if I come up with a way to do this.

Regards,
Andrew

Offline abudwill

  • Full Member
  • ***
  • Posts: 157
  • Karma: 4
Re: OCS, SCXML and JavaScript
« Reply #1 on: September 04, 2014, 05:54:36 AM »
Boy was I confused...

Pre-dial validation endpoint is controlled by OCS option named validation-uri (and a couple of other options need to be set to enable this - details in deployment guide).  For example validation-uri would point to a URL.  OCS will HTTP POST to the URL and send a JSON message body.  External system responds with HTTP 200 - which represents, "yes OCS, it is okay to dial this record", or external system can respond with HTTP 409 - which represents, "no OCS, do not dial this record".  Both responses can include a JSON message body, the key value pairs can map to calling list fields.

Advanced treatments are controlled by an entirely different option, treatment-uri.

This being said, both can be used at the same time.  OCS will perform pre dial validation, and if it passes, the SCXML treatment will be consumed where I can set my CPNDigits.

Interestingly enough, the OCS SCXML engine does implement a Javascript interpreter (Mozilla Spider Monkey).  However Spider Monkey does not implement XmlHttpRequest.

Regards,
Andrew