Integrating Zoho Creator and Zoho Desk using a Widget Extension

In the dynamic realm of customer support, innovation is key to maintaining an edge. Integrating Zoho Creator with Zoho Desk opens up new possibilities, streamlining workflows by bridging communication between platforms. This guide will lead you through the process of crafting a custom widget that links Zoho Creator and Zoho Desk.

Published on September 2, 2024

Share This Post
Zohodesk

1. INTRODUCTION

In the fast-paced, ever-evolving world of customer support, staying ahead is not a luxury—it’s a necessity. Your ingenious foray into the arcane alchemy of Zoho Creator and Zoho Desk integrations can streamline your business processes by enabling seamless communication between different platforms.

In this guide, we will walk you through creating a custom widget that connects Zoho Creator and Zoho Desk. It will let you fetch and display data from a Zoho Creator app in Zoho Desk. This integration is useful for managing warranty info. It allows direct access to customer data stored in Zoho Creator from a Zoho Desk ticket.

2. CREATING THE ZOHO CREATOR APP

You start by creating an application in Zoho Creator to store and organize your data. This section offers a tutorial on building an app. Further, providing guidance on configuring a form for gathering information.

First, log into your Zoho Creator account.

Image 1.1

Click on Create Application. Choose Create from Scratch and then click Create.

Image 1.2

Name your application “Warranty Management.” Click on Create Application. You can enable the environment from here. It lets you add features in a specific environment. So you can test the new features without affecting the live app.

Image 1.3

To capture warranty data, create a new form by clicking Create New Form and select From Scratch.

Image 1.4

Name the form “Warranty Details” and click on Create Form.

Image 1.5

Now, add the following fields to the form to capture warranty information:

  • Email Address (email field)
  • Product Name (single-line field)
  • Warranty Start Date (date field)
  • Warranty End Date (date field)
  • Serial Number (single-line field)

Image 1.6

Click Done to save your form and run a quick test to ensure everything is working correctly.

Image 1.7

3. CREATING ZOHO DESK WIDGET EXTENSION

Now that you have a Zoho Creator app, the next step is to create a Zoho Desk widget. It will fetch warranty information from the Creator app. You must set up a development environment on your computer. Then, use Node.js to create and run your widget.

Start by logging into your Zoho Desk account.

Image 2.1

Navigate to Settings and click on Build Extensions under Developer Space.

Image 2.2

Now, click on Download Node.js under Build Extension.

Image 2.3

Install Node.js using the package manager. There are other ways. But, as we will be working from PowerShell, let’s use this method.

Image 2.4

Open PowerShell as an Administrator and run the command:

‘winget install Schniz.fm’

This installs the Fast Node Manager (fnm).

Image 2.5

Configure the fnm environment by running:

‘fnm env –use-on-cd | Out-String | Invoke-Expression’

Image 2.6

Install Node.js with:

‘fnm use –install-if-missing 20’

Image 2.7

Verify the Node.js and npm versions:

‘node -v’

‘npm -v’

Ensure the versions match those listed on the Node.js website.

Image 2.8

In Zoho Desk, go to the Build Extensions page and click on ZET CLI Tool under Build Extension.

Image 2.9

Install the ZET CLI tool using the following command in PowerShell:

‘npm install -g zoho-extension-toolkit’

Image 2.10

Now, initiate the extension project by running the following command:

‘zet init’

If the command fails, set the execution policy to unrestricted. Run this command, then run ‘zet init’ again:

‘Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser’

Image 2.11

Now, select the Zoho Desk option for your project. Provide a project name. Then, select No when asked if you need the Support Module.

Image 2.12

Then, the widget source files will be downloaded to your computer. Please locate them in ‘C:\Users\Administrator\your_project’.

Image 2.13

Open the ‘plugin-manifest.json’ file in a text editor. Add details like the widget name, logo, and icon under the “widgets” attribute.

Image 2.14

Name your widget by setting the “name” attribute. Provide the logo file path using the “logo” attribute. Set the icon path with the “icon” attribute. Once these details are filled in, save the file.

Image 2.15

The next step is to edit the HTML and JavaScript files. Open ‘widget.html’ file in an editor from the “app” folder.

Image 2.16

Now, add the following code in the ‘<body>’ tag.

<div id=”warranty-info”>

<p>Loading warranty information…</p>

</div>

 

Image 2.17

The ‘widget.html’ file uses HTML to define your widget’s layout. It creates a basic user interface. To implement your widget’s logic, you’ll use the ‘extension.js’ file. Navigate to your project’s directory. Then, go to the “app” folder, the “js” folder, and open the ‘extension.js’ file in an editor.

Image 2.18

Zoho Desk widgets can use the ZOHODESK JavaScript object. It lets them interact with ticket data. To access the ticket’s contact email, use the following code:

// Initialize the widget and fetch ticket information

 

ZOHODESK.get(“ticket.contact.email”).then(function(response) {

const emailObj = JSON.parse(response);

const email = emailObj[‘ticket.contact.email’];

// Now use this email to fetch warranty information

fetchWarrantyInfo(email);

});

 

// The ‘fetchWarrantyInfo’ function will use the email from the ticket.

// It will query the Zoho Creator app for warranty details.

 

function fetchWarrantyInfo(email) {

// Replace with your actual Zoho Creator API URL

const apiUrl = `https://creator.zoho.com/api/v2/YOUR_ZOHO_USERNAME/YOUR_APP_NAME/report/All_Warranty_Details?criteria=(Email == “${email}”)`;

 

// Fetch the warranty information using Zoho Creator’s API

fetch(apiUrl, {

method: ‘GET’,

headers: {

‘Authorization’: ‘Zoho-oauthtoken ‘ + ‘YOUR_OAUTH_TOKEN’,

‘Content-Type’: ‘application/json’,

}

})

.then(response => response.json())

.then(data => displayWarrantyInfo(data))

.catch(error => console.error(‘Error:’, error));

}

 

// Function to display fetched warranty information

function displayWarrantyInfo(data) {

const warrantySection = document.getElementById(‘warranty-info’);

warrantySection.innerHTML = ”;  // Clear previous content

 

if (data && data.data.length > 0) {

data.data.forEach(warranty => {

let warrantyDetails = `

<p><strong>Product Name:</strong> ${warranty.Product_Name}</p>

<p><strong>Warranty Start Date:</strong> ${warranty.Warranty_Start_Date}</p>

<p><strong>Warranty End Date:</strong> ${warranty.Warranty_End_Date}</p>

<p><strong>Serial Number:</strong> ${warranty.Serial_number}</p>

<hr>

`;

warrantySection.innerHTML += warrantyDetails;

});

} else {

warrantySection.innerHTML = ‘<p>No warranty information found for this email.</p>’;

}

}

 

Image 2.19

Before implementing the code, ensure you have your Zoho Creator app API URL. Replace ‘YOUR_ZOHO_USERNAME’ with your Zoho username. Replace ‘YOUR_APP_NAME’ with your app name. Replace ‘All_Warranty_Details’ with the actual form name for warranty details.

Also, replace ‘YOUR_OAUTH_TOKEN’ with your actual OAuth token. We’ll provide guidance on obtaining these values later in the article.

After entering all the necessary details, save the edited project files. The widget is now ready for testing.

To start the server on your local machine, open PowerShell. Then, run ‘cd your_project_location’ to go to your project directory. Lastly, run ‘zet run’ command.

Image 2.20

To test your extension, enable Developer Mode in Zoho Desk.

Before doing so, run the server and open ‘https://127.0.0.1:5000/plugin-manifest.json’ in Google Chrome. Then, click Advanced and click Proceed to Unsafe to access ‘widget.html’.

Image 2.21

If you’re using Firefox, open ‘https://127.0.0.1:5000/plugin-manifest.json’ in a new tab. Click “Advanced,” then “Accept the Risk and Continue.””

If the “Proceed to Unsafe” option is missing, enable the ‘chrome://flags/#allow-insecure-localhost’ flag in Chrome. Then restart the browser.

Next, go to the Build Extensions page in Zoho Desk. Click Enable Developer Mode to refresh the page and activate Developer Mode.

Image 2.22

Now, if you access a ticket in Zoho Desk and navigate to the Marketplace, you will see your widget.

Image 2.23

Since our widget primarily uses JavaScript, it should work fine here; you can test and finalize its UI. After testing, finalize the widget.

Open PowerShell and run the ‘zet pack’ command. It will create a zip file of the widget’s source files. This step is crucial for publishing, as you must provide the widget’s source code in a zip file.

Image 2.24

Finally, run the ‘zet validate’ command to validate all the widget source files.

Image 2.25

4. PUBLISHING THE WIDGET

Now, upload your widget. After packaging your extension, it’s time to publish it.

Open Zoho Desk and navigate to Developer Space. Go to Build Extensions. Click on Sigma under Upload Your Extension.

Image 2.26

Click on New Extension. Enter a name and description for your widget. Select Zoho Desk as the service. Upload the widget’s zip file from ‘C:\Users\your_user_name\widget_name\dist\widget_name.zip.’ Then, click Create.

Image 2.27

After review, click Publish to make your widget live.

Image 2.28

Click the Install URL link. Select the departments and profiles for the widget’s availability. Then, click Install to add the custom widget to Zoho Desk.

Image 2.29

Go to the Tickets section in Zoho Desk to find your widget in Marketplace.

Image 2.30

5. CONNECTING ZOHO CREATOR APP WITH ZOHO DESK WIDGET

To integrate Zoho Desk with Zoho Creator, use Zoho Creator’s REST API to fetch data. To obtain the necessary API URL for your Zoho Creator application:

  • Find the owner name, app link, and report link in Zoho Creator. Your widget will use them to extract data.
  • Open the application and the relevant form in Zoho Creator, where you can find these details in the URL.

Image 3.1

Then construct the Zoho Creator API URL. The basic format of the Zoho Creator API URL is as follows:

https://creator.zoho.com/api/v2/{owner_name}/{app_link_name}/report/{report_link_name}

Replace the placeholders with your actual details:

  • {owner_name}: Your Zoho Creator username or email address.
  • {app_link_name}: The link name of your Zoho Creator application.
  • {report_link_name}: The link name of the report you want to query.

To verify the URL, open it in a browser. Ensure it retrieves the data correctly by checking the file generated.

Image 3.2

To retrieve specific data, such as warranty info from an email, add query parameters to the API URL like this:

https://creator.zoho.com/api/v2/john_doe/warranty_management/report/All_Warranty_Details?criteria=(Email == “example@example.com”)

Next, generate an OAuth access token for authenticating API requests. First, visit the Zoho Developer Console here: https://api-console.zoho.com/. Then, get your token.

Image 3.3

Next, create a new client, e.g., select Self Client as the client type. Enter the required details and click Create to generate the client ID and client secret.

Image 3.4

To generate an authorization code, go to the Zoho API Console and select Generate Code. Enter the required scopes, separated by commas (e.g., ‘ZohoCreator.report.READ’). Choose the validity period for the code, enter a description, and click Create.

The authorization code will then be generated and displayed in a pop-up.

Image 3.5

After obtaining the code, use the following endpoint to exchange it for an access token:

https://accounts.zoho.com/oauth/v2/token?grant_type=authorization_code&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_REDIRECT_URI&code=GENERATED_CODE

Include the parameters client_id, client_secret, redirect_uri (optional), and code in your request.

Now, make a sample API call. Use Postman or any API testing tool to make a request using your API URL and OAuth token. Confirm that you receive the desired data.

Image 3.6

After getting the access token, refresh token, and API URL, use JavaScript to fetch the data. Update the placeholders in the earlier code. Here’s a reminder of the code with the placeholders filled in:

function fetchWarrantyInfo(email) {

const apiUrl = `https://creator.zoho.com/api/v2/john_dou/warranty_management/report/All_Warranty_Details?criteria=(Email == “$example@example.com”)`;

 

fetch(apiUrl, {

method: ‘GET’,

headers: {

‘Authorization’: ‘Zoho-oauthtoken ‘ + ‘2inwubdyd4yryibfhfbdfb44i512bhweveg44ufvw4’,

‘Content-Type’: ‘application/json’,

}

})

.then(response => response.json())

.then(data => console.log(data))

.catch(error => console.error(‘Error:’, error));

}

 

Ensure placeholders are replaced with actual values and keep your OAuth tokens secure. This method enables effective integration between Zoho Desk and Zoho Creator.

Image 3.7

Also, use the exact names of the data fields from the “Warranty Details” form in your JavaScript code.

6. TESTING AND VALIDATING THE WIDGET

After integrating the widget with Zoho Desk, it’s crucial to test the setup. This ensures it meets the intended use case and works as expected.

Navigate to the Tickets section in Zoho Desk, where the widget is installed. Open a ticket and check whether the widget loads properly.

Image 4.1

Check that the widget fetches and shows data from Zoho Creator. It should use the contact email linked to the ticket.

7. CONCLUSION

If you follow the steps, you should have a working Zoho Desk widget. It will integrate seamlessly with Zoho Creator. This setup lets you access crucial data in Zoho Desk. It boosts workflow efficiency and the user experience.

Recent Posts
  • Integrating Zoho Creator and Zoho Desk using a Widget Extension
  • A System Admin’s Guide to Securing Zoho One Using Active Directory (Part II)
  • A System Admin’s Guide to Setting Up Zoho One Using Active Directory (Part I)
  • Zoho CRM Next Gen UI: Using the Interactions Tab
Share This Post

Related Posts

Discover the latest news and updates on Zoho applications.

Unlock Your Knowledge Journey!

Get three articles for free, then enjoy unlimited access by registering.