cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
14790
Views
9
Helpful
60
Replies

Setting a Call Variable using JavaScript

Gerry O'Rourke
Spotlight
Spotlight

Hi,

I can see how to retrieve the ICM call variables using Finesse JavaScript Library e.g.

dialog.getMediaProperties();

But is it possible to set/update the call variables using the Finesse JavaScript Library?

If so, does anyone have a simple example?

Gerry.

1 Accepted Solution

Accepted Solutions

dlender
Level 6
Level 6

Currently you have to override the finesse.js Javascript library Dialog to add an updateCallVariable method like this:

finesse.restservices.Dialog.prototype.updateCallVariable =  function (name, value, options)

    {

        this.isLoaded();

                                var callvar = {

                                                  "name" : name,

                                                  "value" : value

                                };

                                var callvariable = { "CallVariable" : callvar };

        var mediaProperties =

        {

            "callvariables":  callvariable

        };

        options = options || {};

        options.content = {};

        options.content[this.getRestType()] =

        {

            "mediaProperties": mediaProperties,

          // "requestedAction": finesse.restservices.Dialog.Actions.UPDATE_CALL_DATA

                                  "requestedAction": "UPDATE_CALL_DATA"

        };

        options.method = "PUT";

        this.restRequest(this.getRestUrl(), options);

        return this;

    };

In your xml you would have a textbox with a Set CV1 button:

<button onClick="finesse.modules.SampleGadget.updateCallVariable('callVariable1', ($('#callvar1')).val());">Update CV1</button>

updateCallVariable : function ( name, value){

                                clientLogs.log("updating Call Variable " + name + " " + value);

                                clientLogs.log("dialog id: " + currdialog.getId());

                                var options = {};

                                currdialog.updateCallVariable(name, value, options);

                                },

In a future release, the updateCallVariable will be a part of finesse.js

There will also be a SetCallVaribiable sample gadget posted in the near future.

View solution in original post

60 Replies 60

dlender
Level 6
Level 6

Currently you have to override the finesse.js Javascript library Dialog to add an updateCallVariable method like this:

finesse.restservices.Dialog.prototype.updateCallVariable =  function (name, value, options)

    {

        this.isLoaded();

                                var callvar = {

                                                  "name" : name,

                                                  "value" : value

                                };

                                var callvariable = { "CallVariable" : callvar };

        var mediaProperties =

        {

            "callvariables":  callvariable

        };

        options = options || {};

        options.content = {};

        options.content[this.getRestType()] =

        {

            "mediaProperties": mediaProperties,

          // "requestedAction": finesse.restservices.Dialog.Actions.UPDATE_CALL_DATA

                                  "requestedAction": "UPDATE_CALL_DATA"

        };

        options.method = "PUT";

        this.restRequest(this.getRestUrl(), options);

        return this;

    };

In your xml you would have a textbox with a Set CV1 button:

<button onClick="finesse.modules.SampleGadget.updateCallVariable('callVariable1', ($('#callvar1')).val());">Update CV1</button>

updateCallVariable : function ( name, value){

                                clientLogs.log("updating Call Variable " + name + " " + value);

                                clientLogs.log("dialog id: " + currdialog.getId());

                                var options = {};

                                currdialog.updateCallVariable(name, value, options);

                                },

In a future release, the updateCallVariable will be a part of finesse.js

There will also be a SetCallVaribiable sample gadget posted in the near future.

Thanks for the response David.

Gerard.

David,

> There will also be a SetCallVaribiable sample gadget posted in the near future.

Any idea on when this near future will be? weeks / months etc.?

Also it would be good if the Click to Dial Sample Gadget was enhanced (I will post on a dedicated discussion).

Ideally it should change to a Transfer (and allow consult or blind) when agent state changes to talking.

Transfer allows Call Variables to be passed to other agent, while a new call does not.

Gerard.

Last I checked Finesse 10.5 will have setting call variable on a MakeCall.

I will attach a 10.0 example setCallVariable and blind transfer gadget to this post.

Brilliant. thanks David.

David - why doesn't UCCX allow call variables to be passed in via the MAKE_CALL action?    I am really struggling to pass call variable data into UCCX from a CRM that is trying to use the Finesse APIs.   I can't pass the variables via MAKE_CALL and I also can't even update the dialog using UPDATE_CALL_DATA when I authenticate to the Finesse API as an admin user.

Being able to set call variables when an agent makes a call and receives a call directly would be great!  Has anyone been able to do this?  As the SetVariable calls wont update variables that are null.

If you are talking about an ECC call variables, then you could try this...

var callVars = dialog.getMediaProperties();

Then, you can access ECC variables like this:

somevariable = callVars["user.ecc_variable_name"];

That works great if you want to GET the variable. The question was how to UPDATE the variable so your answer is irrelevant.

Here is an example of updating a call variable.

var options = {};

  

currdialog.updateCallVariable(name, value, options);

That only works if you extend the Finesse.js file as documented in the original post. If you do not want to change the Finesse file you can also do it this way:

var callvar = {

   "name" : "CallVarialbe1",
   "value" : "Variable Value"

};

var callvariable = { "CallVariable" : callvar };
var mediaProperties = { "callvariables": callvariable };
var options = options || {};
options.content = {};
options.content["Dialog"] =

{

   "mediaProperties": mediaProperties,
   "requestedAction": "UPDATE_CALL_DATA"
};
options.method = "PUT";
options.success = function() {

  _clientLogger.log("Call Vars updated successfully");
};
options.error = function() {

   console.error("Failed to update call variable");
};
// Update the variables
currDialog.restRequest(currDialog.getRestUrl(), options);

Can we set multiple call variables in a single call?

Yes. You can.

 

Gerry

HI Gerry
Can you please provide a sample?
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: