Interacting with a Script
Use the ‘/call/script’ resource to interact with scripts created in VCC Live’s projects.
To make this work, you need to set a Javascript code in the VCC Live Desk application that can handle HTTP requests, for example:
$().onHttpRequest = (query) => {
vcc.alert(JSON.stringify(query));
}
This needs to be inserted in the Edit code section at project > Script Editor > Edit code
Then, other software can use this GET API to interact with the script:
Request | |
---|---|
Method | GET |
Resource | http://localhost:[port]/call//script?someKey1=someValue&someKey2=value |
Options | N/A |
Body | N/A |
Response | |
Body | Returns the response of the HTTP handler provided by the user in the Request resource. |
The above request’s ‘someKey1=someValue&someKey2=value’ part is available for the JavaScript code added by the user, via the query parameter. In our example here, the query is a variable, that provides the following response in a pop-up window:
{someKey1: "someValue", someKey2: "value"}
If the JavaScript code, provided by the user gets a response, then that will be available in response body.
Example: the following code returns the name of the customer that is currently handled by the agent, in a response body.
$().onHttpRequest = () => {
return vcc.getFieldValue("name");
}
Note: The ‘/script’ API does not work in Test mode, only in Prework, Call or Afterwork states.
Comments
Can’t find what you need? Use the comment section below to connect with others, get answers from our experts, or share your ideas with us.
There are no comments yet.