--- title: "Configure the Event function" url: https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/nodejs/configure-function/ description: "Create an Event Driven Architecture to automate invoice updates from Zoho Books to Zoho Cliq using Event Functions and Catalyst Signals." last_updated: 2026-08-17T12:16:04Z service: All Services type: tutorial related_links: - name: "Event Functions" url: /en/serverless/help/functions/event-functions/ - name: "Functions Directory Structure" url: /en/cli/v1/project-directory-structure/functions-directory --- # 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](https://docs.catalyst.zoho.com/en/cli/v1/project-directory-structure/functions-directory), `functions/Cliq_Notifier` contains: - The `index.js` main function file - The `catalyst-config.json` configuration file - Node modules - `[package.json](https://docs.npmjs.com/files/package.json)` and `[package-lock.json](https://docs.npmjs.com/configuring-npm/package-lock-json.html)` 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: ```sh npm install axios ``` This will install the module. ![installing axios dependencies](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/axios-cli.webp) This will also update the `Package.json` file with **axios** dependency as shown in this image. ![Add dependencies for the fucntion](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/dependency.webp) 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. > **Note**: Please go through the code given in this section to ensure you fully understand it. **index.js** ```javascript const 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**](https://www.zoho.com/in/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](https://www.zoho.com/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](https://help.zoho.com/portal/en/kb/zoho-cliq/user-guides/channels) 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](https://www.zoho.com/cliq/help/platform/bots.html) that has been added to the above channel. - **Zoho Accounts Domain (line 11)**: Mention the [Zoho Accounts](https://www.accounts.zoho.com/) 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](https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/nodejs/register-client/). - **Cient Secret (line 55)**: Paste the corresponding Client Secret generated in [Step 4](https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/nodejs/register-client/). - **Refresh Token (line 58)**: Provide the Refresh Token you generated in [Step 5](https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/nodejs/refresh-token/) using your API client tool. The Event function is now configured.