Building a Simple Microservice

Build a simple microservice using Catalyst Basic I/O Functions and integrate it with Zoho CRM to send automated counter-based email alerts when more than a specific number of leads are created

Test the Function

Before you deploy the function to the remote console and integrate it with Zoho CRM, you can test it locally and check if everything works fine.

You can test and debug a function by launching a node shell from the Catalyst CLI. You can learn about the functions shell in detail from the Working with Functions help page. Let's test the function by launching the functions shell in the CLI.

Navigate to your project directory in your terminal and execute the following command from the CLI:

$ catalyst functions:shell

This opens the node shell. You can now pass inputs, execute the function, and perform other node shell operations in it.

Note: You can launch the function shell with your IDE's debugger attached to it. This will enable you to debug the function line by line in your IDE. You can do this by executing the command: catalyst functions:shell --debug [port]. You can learn more about the functions shell options from the Working with Functions help page.

Let's test the countfunction by passing the input values for feature_name and mail_count_threshold. Execute this command in the function shell:


This assigns the threshold value as '1' for the feature 'CRM'. Therefore, when the function is invoked more than once for the feature, the counter will exceed the threshold limit.

The CLI will invoke the function and pass the input values to the default segment in Catalyst Cache. The counter doesn't exceed the threshold during the first invocation. Therefore, the CLI will just display the output message that we configured for the status code 200.

You can verify if the counter value is added to the cache, by navigating to Cache under Develop in the Catalyst console.

Click Default to open the default segment in the Segments page. You will be able to see a key-value pair added to the segment, with the key name 'COUNTER_CRM' and the value '1' indicating that the function was invoked once.

Now let's invoke the function a second time to exceed the threshold limit. Execute the countfunction({"feature_name":"CRM","mail_count_threshold":"1"}) command again.

This will invoke the function again and increment the counter value. Since the threshold limit of 1 has now been exceeded, the email alert will be sent automatically to the defined receiver email address. The CLI will display the message that was pushed to the logs indicating this.

You can verify this by checking the receiver email.

The value of the counter will also be updated in the cache.

If this setup is working correctly, we can deploy the application to production.