Configure the Event Function
Let us now configure the event function Cliq_Notifier, which automatically sends a message to a Zoho Cliq channel. This message will include the invoice details of new customers who have successfully completed their payment. The function will be executed when it is triggered by Catalyst Signals.
The functions directory, functions/Cliq_Notifier contains:
- The index.js main function file
- The catalyst-config.json configuration file
- Node modules
- package.json and package-lock.json dependency files
You will be adding code in the index.js file.
Our function will require axios package as a dependency for its efficient functioning. axios is a promise-based HTTP client that we will use to send asynchronous HTTP requests to the Cliq API endpoint to post messages.
To install axios, navigate to the Node function’s directory (functions/Cliq_Notifier) and execute the following command:
This will install the module.

This will also update the Package.json file with axios dependency as shown in this image.

Copy the Node.js code and paste it in index.js in the functions/Cliq_Notifier directory of your project, and save the file. You can use any IDE of your choice to work with the application’s files.
index.jscopyconst axios = require('axios'); const catalyst = require('zcatalyst-sdk-node'); const ZBOOKSDOMAIN = "{{YOUR_ZBOOKS_DOMAIN}}"; //Enter your ZohoBooks Domain based on your region const ZBOOKSORG = "{{YOUR_ZBOOKS_ORGANIZATION_ID}}" //Enter your ZohoBooks Organization Id const ZCLIQDOMAIN = "{{YOUR_ZCLIQ_DOMAIN}}"; //Enter your ZohoCliq Domain based on your region const ZCLIQ_CHANNEL_UNIQUE_NAME = "{{YOUR_CHANNEL_UNIQUE_NAME}}" //Enter the unique name of the channel where updates should be posted const ZCLIQ_BOT_UNIQUE_NAME = "{{YOUR_BOT_UNIQUE_NAME}}" //Enter the unique name of the bot that will post the messages const ZACCOUNTSDOMAIN = "{{YOUR_ZACCOUNTS_DOMAIN}}" //Enter your ZohoAccounts Domain based on your region module.exports = async (event, context) => { try { const rows = transformEventData(event.getRawData()); const requestBody = buildCliqRequestBody(rows); const accessToken = await getAccessToken(context); await sendToCliq(requestBody, accessToken); console.log("Message pushed to channel successfully"); context.closeWithSuccess(); } catch (error) { console.error('Error occurred:', error); context.closeWithFailure(); } }; function transformEventData(rawData) { let rows = rawData.data.flat(); for (let row of rows) { const invoiceId = row["Invoice Id"]; delete row["Invoice Id"]; row["Link"] = `https://${ZBOOKSDOMAIN}/app/${ZBOOKSORG}#/invoices/${invoiceId}`; } return rows; } function buildCliqRequestBody(rows) { return { slides: [{ type: "table", data: { headers: ["Customer", "Invoice Number", "Amount", "Paid On", "Link"], rows: rows } }], text: "Here are the invoices marked as Paid in the last hour:" }; } async function getAccessToken(context) { const app = catalyst.initialize(context); var connector = app.connection({ CliqConnector: { client_id: "{{YOUR_CLIENT_ID}}", //Enter your Client ID client_secret: "{{YOUR_CLIENT_SECRET}}", //Enter your Client Secret auth_url: `https://${ZACCOUNTSDOMAIN}/oauth/v2/auth`, refresh_url: `https://${ZACCOUNTSDOMAIN}/oauth/v2/token`, refresh_token: "{{YOUR_REFRESH_TOKEN}}" //Enter your Refresh Token } }) .getConnector('CliqConnector'); return await connector.getAccessToken(); } async function sendToCliq(body, accessToken) { const cliqChannelURL = `https://${ZCLIQDOMAIN}/api/v2/channelsbyname/${ZCLIQ_CHANNEL_UNIQUE_NAME}/message?bot_unique_name=${ZCLIQ_BOT_UNIQUE_NAME}`; const headers = { 'Content-Type': 'application/json', 'Authorization': 'Zoho-oauthtoken ' + accessToken }; const response = await axios.post(cliqChannelURL, body, { headers }); }
Note:After you copy and paste the code into your function file, make sure to update the following placeholders with actual values, as indicated by the inline comments:
Zoho Books Domain (line 4): Enter the domain corresponding to your Zoho Books organization, based on your region. Example: books.zoho.com, books.zoho.eu, or books.zoho.in
Zoho Books Organization ID (line 5): Provide the unique Organization ID of your Zoho Books account.
Zoho Cliq Domain (line 7): Specify the domain of your Zoho Cliq organization, based on your region. Example: cliq.zoho.com, cliq.zoho.eu
Unique Name of your Zoho Cliq Channel (line 8): Enter the unique name of the Zoho Cliq channel where the paid invoice updates should be posted.
Unique Name of your Zoho Cliq Bot (line 9): Provide the unique name of the Zoho Cliq bot that has been added to the above channel.
Zoho Accounts Domain (line 11): Mention the Zoho Accounts domain used to log into Catalyst, Zoho Books, and Zoho Cliq. Example: accounts.zoho.com, accounts.zoho.in
Client ID (line 54): Paste the Client ID obtained during client registration in Step 4.
Cient Secret (line 55): Paste the corresponding Client Secret generated in Step 4.
Refresh Token (line 58): Provide the Refresh Token you generated in Step 5 using your API client tool.
The Event function is now configured.
Last Updated 2025-06-10 18:26:01 +0530 +0530