cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5724
Views
10
Helpful
27
Replies

Using REST step in scripts

mr_cisco_cisco
Level 1
Level 1

A common requirement in contact centers is to allow a supervisor to manually close the queue.  The typical approach I see is to create an XML file that stores the state of the queue.  When someone calls the contact center, the script reads the XML file for the state of the queue. 

 

I'm wondering if it's possible to do this without xml files and instead use a REST API.  The idea is you have a boolean value in the script called say, state, and make it a parameter.  Then use a configuration API to set this value to TRUE or FALSE. 

 

I'm referring to the API here:

https://developer.cisco.com/docs/contact-center-express/#introduction/supported-operations

 

Has anyone tried this?  Any pitfalls to be aware of?

27 Replies 27

Really? Wow. That seems like an oversight. Ok, so I just checked the documentation, and sure enough, downloading prompts and scripts is documented, but not documents.

I tried it anyways, and it certainly failed, with "Instance Not Found."

Alright, well, then in the absence of being able to download a document from the document repo, I'd suggest using an HTTP Triggered Application, which takes a filename parameter, and then serves up the contents of a file from the document repository, for which one would then read in, parse, change, and finally, using the Admin API, upload and overwrite the existing document in the document repository.

Such a script could be as simple as:

Start
filename = Get HTTP Contact Info (--Triggering Contact--, "filename")
Send HTTP Response (--Triggering Contact--, doc[filename])
End

I know this is a bit of an older thread but I was using it for some good information in accessing information through the API as well as cross referencing it with other information I found on the web and just wanted to include this as a solution for downloading the documents as I found this solution in other threads and wanted to make it available to others searching the web and come across this thread.  To access documents on the UCCX server you do not need to use the API which is probably why the download function does not work on documents in the API.  You can access documents directly through a standard web call:  

 

http://<UCCX Server>:9080/documents/

 

Thanks.

That's pretty handy, thanks for sharing. There are a few hidden URIs on port 9080, and it would be great if Cisco would just document them. E.g., /realtime (https://community.cisco.com/t5/contact-center/agent-stats-for-uccx/td-p/3367492)

 

EDIT: I just tried the documents one on 11.6(2)ES02 and it doesn't work.

I have 11.6(ES01-9) and it works.  Here is the format I am using, don't need the language in the call.

 

http://XX.XX.XX.XX:9080/documents/Schedules/test.xml

My fault, I didn't specify a document. I assumed it was going to produce a list of documents. :)

And now that I have it working with a path to a file, I can also add that HTTPS works to:

https://<uccx server>:9443/documents/anthony.txt

Along these same lines I have been searching for a solution but have not found any examples yet.  Does anyone have a good example of python code generating and uploading XML as a document.  I have been able to figure out the correct steps using Postman but wanted to see if there was some code that people were using in which they were generating and/or reading an XML file from the server making changes to it and uploading it to the server.  I don't have Premium only Enhanced so I am not able to use triggered scripts and so will be using a Python based web page to allow Supervisors to be able to make changes to XML files that are used to control schedules and xml files that are used to schedule one time closures.  Thanks.

I'm going to take a guess that you don't know python and/or python requests very well, and if I'm right, I highly recommend learning/reading about python requests.

The documentation is very easy to read, if you know python:
http://docs.python-requests.org/en/master/

It will allow you to access the URLs on UCCX via REST API or that :9080/documents URI, and then POST/PUT data back on UCCX via the REST API.

I use python requests exclusively for all of my web calls (REST or otherwise), and it's fantastic.

Examples:
https://twitter.com/avholloway45633/status/647450649353846784
https://cisco-voip.markmail.org/thread/3h4wcgyaonbiadyr

You are correct in the fact that I am relatively new to Python on Requests, but have had some experience in them.  The problem I am having is getting the request set up correctly to be able to upload a string of xml data and have it placed as a file on the server.  Below is what I have come up with, but am getting a malformed request response from the server.

 

 

image.png

 

 

 

 

Thanks.

After a little more work and effort I figured it out.  This uploads it to the temp storage and I can then move it into the real final file.  Thanks...

 

image.png

 

How are you moving it? Also, why not just serve up the XML to UCCX from your server? E.g., in UCCX just use: Set http_resp = URL[http://yourserver/yourpath/]

Because, didn't you say that you're building a web front end for end users to modify the file contents?

Anthony, you are correct that I could be just serving it from the server and I had considered that, but I chose to host the files on the UCCX server and modify them on the UCCX server just to take care of redundancy and reliability issues, I did not want to introduce another server that made the availability and functionality of the UCCX server dependent on it.  

 

I work for a medical institution and while we use UCCX for several call center type functions, I am also moving a lot of the clinic IVRs over to it as it allows us the ability to use the programability to create some standards in menu systems and other features including advanced scheduling.  One of the features I am looking to give supervisors without giving them UCCX access, is the ability to schedule a closure on a clinic.  (Could be weather related, or could be because of a meeting, etc...) As there are no associated queues I wanted to give them the ability to do it through a web interface because the people the schedule these closures are doing it for several clinics and to do it through a phone interface would be time consuming and difficult.  So the best way I have found is I have created a scheduling script that I re-use across all of my scripts and one of the things that scheduling script checks for is a forced-closed XML document that gives a start date and time and end date and time.  In the script I check if the current date and time is between the begin and end.  All of that to say that while it is important that people be able to close the queue when needed I did not want to have a dependency between UCCX and the outside server, such that if the outside server were to stop functioning then the UCCX server could continue on with no impact.

 

As far as how I moved the file from temp location to permanent location here is the rest of the test script.    

 

image.png

Oh ok, I see how you did it now. The thing that was throwing me off was the two-step process, but I got it now. Thank you for sharing.

PS, I noticed that, while your first upload works, the content type of applicaiton/xml should be multipart/form-data, according to this page: https://developer.cisco.com/docs/contact-center-express/#!upload-files-to-a-temporary-folder

Hi Can any help on me on this, My requirement is like I wnat to upload a recorded .wav file to an external server, so I have created a rest api which will accept mutrpart/form-data and it upload the file to the server and its working fine.

Now from uccx script I want to call that rest api(post) with the recorded .wav file but I'm not sure how to set the body in REST call component. I'm attaching both the snippet of rest call from uccx and the API calling from postman and also the script.Any suggestion is appreciable.

API.JPGrest call.JPGCapture.JPG

 

 Thanks.