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

Initialize the Project

You can now begin working on your Catalyst project from the CLI. The first step is to initialize the project in an empty directory. This will be the home directory of your project, and all of the project files will be saved in it.

You can learn more about this from the Project Directory Structure help page. You can learn about initializing a project in detail from the CLI help documentation.

For this microservice, we will initialize the function component.

  1. Create a folder for the project on your local machine and navigate to it from the terminal.
  2. Initialize a project by executing the following command from that directory:
    $ catalyst init
  3. Select Functions using the space bar. Press the Enter key to initialize.
    microservice_project_init
  4. The CLI will now ask you to associate a Catalyst project with the directory. Associate it with the project that we created earlier from the console. Select CounterBasedAlert from the list and press Enter.
  5. The CLI will initiate the functions set up. Select the BasicIO from the list to set up and press Enter. You can learn about the function types from the Functions help page.
  6. Select the latest runtimes of Java or Node.js as the stack and press Enter.
  7. If you had selected Node.js enter "counter_based_alert_function" as the package name, "index.js" as the entry point, and your email address as the author and press Enter. You can alternatively press Enter without entering inputs to fill in the default values. The CLI will prompt the initialization of the Node dependencies. Press Y to confirm the installation, and press Enter to confirm your choice. The Node modules will be installed.
    microservice_node_init
  8. If you have selected Java, enter the name of the Java function and the folder as "countfunction" and press Enter. This is also its reference name. Enter the name of the main class as "CountAlert", and press Enter.
    catalyst_microservice_init_6
Note: Ensure that you enter the main class name and the function's name exactly as instructed, because the application's code contains the same names.

The project and function initialization is now complete.

The current project directory will be created in the standard structure. The functions directory will be created in your project directory with the configuration files and dependencies, along with the catalyst.json and a hidden .catalystrc file:

  • This is the structure of the CountBasedAlert project's directory if the Basic I/O function is of the Node.js platform.

    microservice_node_directory
  • This is the structure of the CountBasedAlert project's directory if the Basic I/O function is of the Java platform.

    microservice_java_directory