Using the WWW tool in RingCX
============================

About the WWW tool

The WWW tool has a wide range of uses. You can use it to make web requests from within your script to a server of your choosing. Pull data from external resources into a script or submit data at any point in a script to any internet-accessible website or destination. Fetch, create, update, and delete resources with the following request methods: *Get* , *Put* , *Post* , *Patch* , and *Delete*.

WWW tool uses

Say you want an agent to see all the tickets a customer has opened while on the call with them. Use the WWW tool in your script to send a request to your CRM for all tickets related to the customer on the call. Then direct the system to display those results in the script however you choose, whether in a table or a dropdown menu --- or in any element or tool available.

Or say your agent is collecting important information from a lead and you want to update the lead file in your CRM or database in real time. You can use the WWW tool to update your lead records with a simple *Put* , *Post* , *Patch* , or *Delete* request ---and the command will execute as the agent continues following the script.

Enabling traffic origination (CORS)

Please note that in order for the WWW tool to work properly, your system must be [CORS-enabled](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS ""); that is, you must support the 'access-control-allow-origin' method. You can either enable traffic origination from our domain alone, or you can enable traffic origination from any domain. To enable CORS, you must support the [OPTIONS HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS "") method type, and in the response, include Access-Control-Allow-Origin"\*".

Returned content

Your returned content type is dictated by whichever body encoding you choose: *Form, XML, JSON,* or*Text*. You can check this out via the content header section in your browser's developer tools.

Remember that the *Get* and *Delete* methods will not contain *Body* text, but *Put* , *Post* , and *Patch* will. When using *Put* , *Post* , or *Patch* , you won't need to use the **Add Variable** setting unless you're using form encoding for the body of your request. Alternatively, you can simply write in the body request yourself in *XML, JSON* , or *Text*.

To set up a WWW request, follow the steps below.

  *  
  Drag the WWW tool from the toolbar onto the canvas

  *  
  Click **Edit** to enter the tool configuration window

  *  
  Name your tool using the **Tool Name** field at upper right

  *  
  Select a request method from the left corner of the dropdown menu: *Get* , *Put* , *Post* , *Patch* , or *Delete*

  *  
  Enter your API request in URL format in the provided text box

  *  
  Click the **Body** tab to choose a format for your body data: *Form* , *XML* , *JSON* , or *Text*. Please note that if you wish to add variables to your request, you must select the Form setting from the radio list of body types at upper left

  *  
  Use the **Headers** and **URL Params** tabs to add variables to your request as needed

    *  
    Click the **Add Variable** plus sign icon to add a variable

      *  
      Enter a **Name** for your variable

      *  
      Enter a **Value** for that variable, and/or use the tag button at far right of the **Value** field to generate or modify your value

    *  
    Repeat as needed

  *  
  Click the **Send**button at far right of your request field to execute the request

  *  
  Use the **Result** setting located under all three tabs (**Headers** , **URL Params** , and **Body** ) to choose an output format for your data: *Form* , *XML* , *JSON* , or *Text* ![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-tool-in-RingCX/images/image1.png)

Don't forget to test your request to ensure you've configured all settings to achieve your desired result.

Testing your WWW requests

If you're curious about your web service payload details, you can use a site like webhook.site to test your webhooks and HTTP requests. Use the site to generate a sample URL, then paste it into the *Put* method bar in the WWW tool configuration window and click **Send**.

Utilizing your WWW request results

Now that you've made your request, let's find out how to use it (when a response is applicable).

If you want to see --- or use --- the results of your request, you'll find your response located on the tool's model object (you can read more about model objects here). To reference it, you can use the **{{model.ToolName}}** syntax, wherein 'ToolName' simply stands for whatever name you gave to that WWW tool. Let's try it in an example.

Say you want to make sure your agent has their identifying information at hand in case a customer asks for it while on a call or chat.

One way is to use the WWW tool to fetch the agent's group name and ID number and then display that information in a table in your script so the agent can refer to it as needed. Let's try that method below.

First, open the WWW tool, name it, and choose your request method. In this case, we'll use *Get* . Enter the URL for the information you wish to retrieve into the field next to the *Get* menu, and if needed, include any relevant parameters either in the URL itself or via the **URL Params** tab below.

![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-tool-in-RingCX/images/image2.png)

In this case, we're hitting an API endpoint in the platform's system, so we'll need to pass an authorization token to ensure that request can access the information. That token (and a host of other relevant information) can be found in your browser's developer tools.

Using developer tools to view request information

Open the page you want to retrieve information from, then open up your developer toolbox and click on the **Network** tab to view your URL and check that the domain is CORS-enabled (remember, you'll see an asterisk in the **Access-Control-Allow-Origin** response header if it is enabled):

![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-tool-in-RingCX/images/image3.png)

Scroll down a little further to view your request headers information and you'll find that authorization token you're going to need if you want permission to access this endpoint via the WWW tool:

![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-tool-in-RingCX/images/image4.png)

Now we can head back to our script and enter that token as a variable via the **Headers**tab:

Click **Send** to preview your request and ensure it's working as intended:

![](https://assets.ringcentral.com/content/dam/xml-assets/doc_team/en_us/ringcentral/RingCX/Using-the-WWW-tool-in-RingCX/images/image5.png)

Success! The data appears in the **Result** field (in the example above, it's in *JSON* format, which you can see is the selected format just above the code block). Feel free to toggle on the *XML* or *Raw* radio button if you wish to view your result in a different format.

Now we can insert that data into a table and display it for agents on the next page in the script:

