Lets understand how to create custom application alerts and send notifications using CloudHub connector…..
The CloudHub Connector provides the ability to interact with CloudHub within Mule application. Using the CloudHub connector, we can send the custom notification from your mule application to CloudHub. It is used for other operations as well such as starting, stopping, deploying, and updating Mule applications the Mule application to CloudHub.
Add a CloudHub connector in Anypoint studio
- First of all, you have to go on your ‘Mule Palette’ and then you have to write CloudHub in Search box. If CloudHub connector is installed, it will be visible in mule Palette. Else will select ‘Search in Exchange’ where you can add the dependencies by searching them in Exchange.
- Search for the CloudHub connector
- Select, add and click on Finish. The connector will be added successfully in the Mule Palette.
Get Environment ID
- This article describes how to get the Environment ID of an Environment inside your Organization. https://help.mulesoft.com/s/article/How-to-get-the-Environment-ID
Steps to Trigger Custom Notification
There are 2 steps to send the custom notifications.
Step 1) Trigger Custom notification from Mule Application to CloudHub.
Step 2) Trigger Alerts to send the CloudHub Notification.
Step 1) Trigger Custom Notification from Mule Application to CloudHub
- Create a new project as “custom-notification”.
- Add a Listener.
- Search the CloudHub connector in Mule Palette.
- Select the Create Notification and drag in the component in flow.
- Click on adding Connector configuration
- Update the Connector Configuration
- Update the Domain (Application Name), Alert Message, custom Properties, Alert Notification Priority and Transaction ID.
- Run the Application and trigger the Alert Notification for the same.
- Click on the notification Icon in CloudHub Runtime and You can see the Alert in CloudHub Notifications as below :
Step 2) Trigger Email notification for CloudHub Notification Click on the Alert Button in CloudHub Dashboard
- Click on the Alert Button in CloudHub Dashboard
- Click ok “create an Alert” option as below :
- Update the Required information for Creating the Alert notification.
- Update the Alert name (Ex: Trigger Custom Notification), Severity Level (Critical, Warning or Info, Based on Requirement), Application Type as CloudHub, Application Name (which will trigger the Alert Notification, Ex. Custom-Notification)
- Update the Alert Condition
- Select the priority from the Priority menu or leave the priority as Any to send notifications regardless of priority.
- In Contains, enter the string to use to trigger a notification. This string must match a string in the Message field that you configured in CloudHub Connector.
Note : There are multiple pre-defined Conditions we can create Alert Based on requirement but in this case, we created Custom Alert Notification as “Custom Application notification” (Alert name will be same as the Application Name)
- Update the Email Subject and Email Message Body to include in the notification email.
- Update the Email Recipients for notification recipients.
- Once Notification Alert Trigger, we will receive the email on Recipients Email Address.
You can use variables in the alert Subject and Message fields. For information about using variables in alerts, see Alert Variables.
When you trigger the alert, the specified recipients receive an email with the custom message you added to the app.
Note : CloudHub stores up to a maximum of 1000 notifications per application. If the number of notifications exceeds the maximum, CloudHub deletes the oldest notification. Each notification can contain up to 10,000 characters.
In this Blog, we learned how to create custom Alert notification in Mule4 using CloudHub Connector.