Zoom Contact Center Script Widget – Part 1 (Hello World)

I recently needed to implement an API lookup in Zoom Contact Center to retrieve customer data to allow call routing to be done more efficiently for existing customers.

The brief was fairly simple – call and API and retrieve a handful of variables and then make some routing choices based on the data retrieved.

Coding Documentation For The Rest Of Us

I am not a programmer. I didn’t even play one on TV. I went to uni for 3 semesters, which involved me religiously attending my CS classes and being at home on the lounge watching A Country Practice when I should have been learning physics and maths. I learned some C++ there, have messed around with websites and done stupid things with VBA in Excel later. I know my If statements, Loops, Functions – but that is about it.

When I have to pick up something new and do some light programming it takes A LOT of googling and a lot of frustration. Ideally I would like some sample code to work with and a lot of explanation of what I am working with.

Instead I often find instead that all documentation is written for people who work with code day to day, and the suggestion to just “import x,y,z libraries and then make a RESTful API call with a JSON object attached” don’t really cater to muppets like me. I really need the basic stuff spelled out for me 🙁

Zoom Contact Center definitely falls into that category – it assumes a lot of knowledge in the documentation. Zoom provides code examples for the Zoom Script widget in two places – within the Widget itself and in their knowledge base.

Getting Started

Log into your Zoom tenancy, navigate to the Contact Center area, into Flows and add a new flow. Within that flow, add a new Script widget and then add a script to the widget.

Here we get our first piece of information about what is going on – the script is going to be in Javascript.

If you do a little more digging you will find that Zoom are using the Axios client within Javascript to power http requests to third party sites.

I’m not sure if there are plans to release other languages in the future – but for now Javascript is what we have.

Open the new script and you will see some light example code:

This really doesn’t give me as a non Javascript programmer enough to work with. I have questions like:

  • Do I need to declare my variables
  • I want to use var_set(string, string); – what order am I providing those variables in? Do they need to be in quotation marks? Double or single?
  • I want to use req.post(url[, data[, config]]); – how do I attach a JSON body to this? How do I auth with it?

and innumerable other questions.

The next place we can go to look at more information is the support file entry for the Script object:

Where do I start?

  • I just get the example I get from the Script widget.
  • “Add all dependencies to your code. See lines 2 to 4 in the example code below.

    What does this mean? Can I call packages? How and when?
  • “Pass your function to module.exports”. What is module.exports. What is “my function”. Why would something need to extract my code? (Note – I suspect that this syntax relates to the OLD version of the scripting language that was deprecated in 2022 – but I am not 100% sure)

Maybe for someone who is a programmer this all makes sense – but to me it doesn’t.

The other place we can look is the linked article “Script Widget Examples“. This gives me a lot more information – but still leaves me foundering somewhat:

This still assumes WAY too much Javascript knowledge for my liking. So lets break it down as if I were an idiot (because I am) and do some good old fashioned “Hello World” examples.

Hello World in Zoom Contact Center Script Widget

We can start by clearing out the example code from the editor window. If you need to refer to it later, you can just drop a new script widget in. Put the following code in your script box and click “run”

async function main () {
	log.debug('Hello Word');
	
}

We can see that the log.debug has done it’s job and output our “Hello World” message to the result box.

Because we are passing a string to the log.debug function we need to encase it is quotes. Javascript is pretty chill about which quotes you use – you can use a single quote mark (‘Hello World’) or a double quote mark (“Hello World”).

You can find plenty of arguments if you search the internet – just choose one and stick to it is my opinion. I like single quotes.

Leave a Comment