Hello Biginners!
In our previous forum post, we explored creating connections - specifically,
custom service connections in the Bigin Developer Console. In this post, we'll focus on another feature that can be used in every topping: install actions.
We'll look at what install actions are and when to use them, and then we'll walk through a real-world example where users are notified whenever a topping is installed or uninstalled.
What are install actions?
Install actions are important features of a topping that let you execute custom logic during installation and uninstallation events.
Instead of treating installation and uninstallation as silent background events, the Bigin Developer Console allows you to run your own logic the moment a user installs your topping, updates it, or decides to uninstall it. This logic can be implemented as Deluge functions that are executed automatically based on the installation action.
Primarily, install actions are executed in the following scenarios:
- On Installation: This action is triggered when the topping is installed for the first time or when the topping is upgraded. (A topping upgrade refers to a new version of the topping being installed by the organization user.) In both cases, the On Installation action runs to perform the required logic.
- On Uninstallation: This action is triggered when the topping is uninstalled or removed from an organization.
Let's look at each of these in detail.
On Installation
The On Installation action is triggered immediately after a topping is successfully installed or updated in a Bigin organization. Conceptually, this is the topping's first run and the right place to perform one-time setup tasks that you don't want users to handle manually.
Note: You can write only one On Installation script per topping. This script is executed only during two key events of the topping: the topping being installed for the first time and an updated version of the topping being installed after publishing changes.
This means the On Installation script is not executed repeatedly. It runs only when the topping is installed or updated, ensuring that setup logic is executed only when it's actually required.
To create an On Installation script, access the Bigin Developer Console, navigate to the Install Actions section in the left panel, and choose Toppings.
You'll be redirected to the Deluge editor where you can write the script for the On Installation action.
In the right panel of the Deluge editor, you'll be able to find the installParamMap which contains important contextual details such as the organizationId, installerId, previousVersion, and other details that are provided by the install action script itself. These keys can be used within your script to perform custom logic based on the installation context.
On Uninstallation
The uninstallation process of a topping will be handled by the On Uninstallation action. This function runs when a topping is removed from an organization.
To create an On Uninstallation script, navigate to Install Actions in the left panel, choose Toppings, and write the script in the On Uninstallation section of the Deluge editor.
In the On Uninstallation action, the installParamMap provides the keys organizationId and installerId. These values indicate which organization the topping is being removed from and which user initiated the uninstallation.
Now that we've explored how both of the install actions work, let's move on to creating a topping using these actions in a real-world scenario.
Let's create a topping with install actions
To understand how install actions work in a real-world scenario, we’ll build a Compliance Notification Topping.
The purpose of the topping is to keep organization administrators of the Bigin account informed about the lifecycle of the topping—specifically when it becomes active and when it's removed from their Bigin account.
In many business environments, it's important for admins to be aware of compliance-related changes and system-level additions. Using install actions in the topping ensures that such notifications are handled automatically, without requiring any manual effort from the user.
To achieve this functionality, we'll rely on both of the install actions:
- When a user installs the topping, the On Installation action is triggered, through which an email notification is sent to all active admin users in the organization, informing them that the Compliance Notification Topping has been successfully enabled. Along with this, a compliance checklist document stored in Zoho WorkDrive is also attached to the email.
- When the topping is uninstalled, the On Uninstallation action is triggered, sending an email notification to all active admin users in the organization to inform them that the Compliance Notification Topping has been successfully enabled. A compliance checklist document stored in WorkDrive is also attached to the email.
Let's learn how to do this.
Setting up the topping
First, create a topping in the Bigin Developer Center. For detailed instructions on creating a topping, refer to this post on
how to create a topping.
After creating a topping and accessing it in the Bigin Developer Console, the next step is to create the required service connections.
A connection for Bigin will be used to fetch admin users from the organization into the topping. In this connection we'll use the scope ZohoBigin.org.ALL, as we need to retrieve the org details of the Bigin account where the topping is installed.
Next, we need a WorkDrive connection because we need to download the compliance checklist file stored in WorkDrive and attach it to the notification email. For the WorkDrive connection, we'll be using the scopes WorkDrive.files.READ and ZohoFiles.files.READ.
For a detailed explanation of creating the default connections, refer to
this post.
Once the connections are created, we can write the install action scripts.
Implementing the scripts
When the topping is installed, we need to send an email to all the active admin users with the installation details and the WorkDrive checklist as an attachment.
To begin, navigate to the Install Actions section in the left panel and select Toppings. Under the On Installation tab, we’ll write the Deluge script that needs to be executed when the user installs the extension.
Writing the On Installation script
In our topping, the On Installation script performs the following actions:
- Fetches all the active admin users in the organization
- Downloads the checklist file from WorkDrive
- Sends an email notification to the admin users with the installation details and the checklist file.
- topping_name = "Compliance Notification Topping";
- // 1) Fetch admin users
- resp = invokeurl
- [
- url :"https://www.bigin.com/developer/docs/apis/v2/get-users.html"
- type :GET
- connection:"biginplus__biginnewconnection"
- ];
- // 2) recipient list
- stakeholders = List();
- usersList = resp.get("users");
- if(usersList != null)
- {
- for each user in usersList
- {
- email = user.get("email");
- status = user.get("status");
- if(email != null && (status == null || status.toLowerCase() == "active"))
- {
- stakeholders.add(email);
- }
- }
- }
- // 3) Download WorkDrive file via Download API
- header = Map();
- header.put("Accept","application/vnd.api+json");
- resource_id = "khw4zbab917b7f4774260a06636089ef0074f";
- fileResp = invokeurl
- [
- url :"https://download.zoho.com/v1/workdrive/download/" + resource_id
- type :GET
- headers:header
- connection:"biginplus__zohoworkdriveconnection"
- ];
- // 4) constructing email
- org_id = installParamMap.get("organizationId");
- installer_id = installParamMap.get("installerId");
- current_time = zoho.currenttime;
- subject = "Bigin Topping Enabled: " + topping_name;
- message = "";
- message = message + "<b>" + topping_name + "</b> was <b>Installed</b>.<br/><br/>";
- message = message + "<b>Organization ID:</b> " + org_id + "<br/>";
- message = message + "<b>Installed by (User ID):</b> " + installer_id + "<br/>";
- message = message + "<b>Time:</b> " + current_time + "<br/><br/>";
- message = message + "<b>Business impact:</b> This topping is now active for the organization.<br/>";
- //sending the email
- if(!stakeholders.isEmpty())
- {
- sendmail
- [
- from :zoho.adminuserid
- to :stakeholders
- subject :subject
- message :message
- Attachments :file:fileResp
- ]
- }
Writing the On Uninstallation script
When a user decides to remove the topping, we'll send an email notification to ensure the admins stay informed.
- topping_name = "Compliance Notification Topping";
- // Fetch admin users
- resp = invokeurl
- [
- url :"https://www.zohoapis.com/bigin/v2/users?type=AdminUsers"
- type :GET
- connection:"biginplus__biginnewconnection"
- ];
- stakeholders = List();
- usersList = resp.get("users");
- if(usersList != null)
- {
- for each user in usersList
- {
- email = user.get("email");
- status = user.get("status");
- if(email != null && (status == null || status.toLowerCase() == "active"))
- {
- stakeholders.add(email);
- }
- }
- }
- org_id = installParamMap.get("organizationId");
- uninstaller_id = installParamMap.get("installerId");
- current_time = zoho.currenttime;
- subject = "Bigin Topping Disabled: " + topping_name;
- message = "";
- message = message + "<b>" + topping_name + "</b> was <b>Uninstalled</b>.<br/><br/>";
- message = message + "<b>Organization ID:</b> " + org_id + "<br/>";
- message = message + "<b>Uninstalled by (User ID):</b> " + uninstaller_id + "<br/>";
- message = message + "<b>Time:</b> " + current_time + "<br/><br/>";
- message = message + "<b>Business impact:</b> This topping is no longer available from now on.<br/>";
- if(!stakeholders.isEmpty())
- {
- //Send email
- sendmail
- [
- from :zoho.adminuserid
- to :stakeholders
- subject :subject
- message :message
- ]
Once we've configured both the On Installation and On Uninstallation scripts, we can
test and publish the topping. When the user installs the topping, the install actions will be triggered automatically based on the topping's lifecycle events.
Let's walk through what happens at runtime.
What happens when the topping is installed or uninstalled
Upon installation, the user receives an email notification along with the topping checklist attachment as shown below.
When the topping is uninstalled, the user receives an email indicating that the topping has been disabled as shown below:
In this post, we've explored how install actions and uninstall actions give us control over the toppings. We'll cover more features of the Bigin Developer Console in our upcoming posts.
Stay tuned!