--- title: "Configure the Event function" url: https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/python/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 `main.py` main function file - The `catalyst-config.json` configuration file - The `requirements.txt` file to mention any external libraries that you might add. You will be adding code in the `main.py` file. Our function will require `requests` library and Catalyst SDK as dependencies for its efficient functioning. To install them, navigate to the function's directory (`functions/Cliq_Notifier`) and create a lib folder. Execute the following command from the lib folder: ```sh pip3 install requests zcatalyst-sdk -t . ``` This will install the dependencies. ![installing requests dependencies](https://catalyst-docs-development.zohostratus.in/images/tutorials/invoice-notifier/requests-cli.webp) > **Note:** Please go through the code in this section to make sure you fully understand it. Copy the python code and paste it in `main.py` 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. **main.py** ```python import sys sys.path.insert(0, 'lib') import logging import traceback import requests import zcatalyst_sdk logger = logging.getLogger() zbooksdomain = "{{YOUR_ZBOOKS_DOMAIN}}"; #Enter your ZohoBooks Domain based on your region zbooksorg = "{{YOUR_ZBOOKS_ORGANIZATION_ID}}" #Enter your ZohoBooks Organization Id zcliqdomain = "{{YOUR_ZCLIQ_DOMAIN}}"; #Enter your ZohoCliq Domain based on your region zcliq_channel_unique_name = "{{YOUR_CHANNEL_UNIQUE_NAME}}" #Enter the unique name of the channel where updates should be posted zcliq_bot_unique_name = "{{YOUR_BOT_UNIQUE_NAME}}" #Enter the unique name of the bot that will post the messages zaccountsdomain = "{{YOUR_ZACCOUNTS_DOMAIN}}" #Enter your ZohoAccounts Domain based on your region def handler(event, context): try: data = extract_invoice_data(event) rows = transform_invoice_data(data) request_body = prepare_cliq_request(rows) access_token = get_access_token() send_to_cliq(request_body, access_token) logger.info("Message pushed to channel successfully") context.close_with_success() except Exception as e: logger.error("An unexpected error occurred:\n%s", traceback.format_exc()) context.close_with_failure() def extract_invoice_data(event): event_payload = event.get_raw_data() data = event_payload.get("data") rows = [invoice for invoices in data for invoice in invoices] return rows def transform_invoice_data(rows): for row in rows: invoice_id = row.get("Invoice Id") row["Link"] = f"https://{zbooksdomain}/app/{zbooksorg}#/invoices/{invoice_id}" del row["Invoice Id"] return rows def prepare_cliq_request(rows): request_body = { "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:" } return request_body def get_access_token(): app = zcatalyst_sdk.initialize() connector_config = { "CliqConnector": { "client_id": "{{YOUR_CLIENT_ID}}", #Enter your Client ID "client_secret": "{{YOUR_CLIENT_SECRET}}", #Enter your Client Secret "auth_url": f"https://{zaccountsdomain}/oauth/v2/token", "refresh_url": f"https://{zaccountsdomain}/oauth/v2/token", "refresh_token": "{{YOUR_REFRESH_TOKEN}}" #Enter your Refresh Token } } connector = app.connection(connector_config).get_connector("CliqConnector") access_token = connector.get_access_token() return access_token def send_to_cliq(payload, access_token): cliq_channel_url = f"https://{zcliqdomain}/api/v2/channelsbyname/{zcliq_channel_unique_name}/message?bot_unique_name={zcliq_bot_unique_name}" headers = { "Content-Type": "application/json", "Authorization": f"Zoho-oauthtoken {access_token}" } response = requests.post(cliq_channel_url, headers=headers, json=payload) response.raise_for_status() ``` > **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 11)**: 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 12)**: Provide the unique Organization ID of your Zoho Books account. - **Zoho Cliq Domain (line 14)**: 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 15)**: 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 16)**: 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 18)**: 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 70)**: 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 71)**: Paste the corresponding Client Secret generated in [Step 4](https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/java/register-client/). - **Refresh Token (line 74)**: Provide the Refresh Token you generated in [Step 5](https://docs.catalyst.zoho.com/en/tutorials/invoice-notifier/java/refresh-token/) using your API client tool. The Event function is now configured.