Email Notification Using Anypoint Runtime Alerts and Cloudhub Connector
This article demonstrates how to create an email notification using the Cloudhub connector create-notification operation and Anypoint Runtime Alerts.
Join the DZone community and get the full member experience.
Join For FreeEmail notification is the most common non-functional requirement in the integration projects and MuleSoft has an inbuilt capability to achieve this and no need to go for the SMTP server.
Below are the steps to create an email notification.
Create Notification
We can create a custom notification from any application using the Cloudhub connector's create-notification operation. Refer to the MuleSoft documentation for the Cloudhub connector configuration and operation details.
https://docs.mulesoft.com/cloudhub-connector/1.0/
The message field will contain the notification message and you can define the priority depending on the message.
Once the notification is created, it will be visible on the runtime manager - click on the bell icon in the right corner.
Create Alerts
We can create alerts from the Alert tab present in the Runtime Manager.
Click on the + sign present on the right corner to create an alert. You will see below window.
Select the condition as a "Custom application notification."
Refer the Alerts documentation on the MuleSoft documentation to create an alert depending on the business requirement.
You can create a generic alert for all applications or create separate alerts based on a logical grouping or any other criteria.
After completing the above 2 steps, you will start receiving an email whenever a notification is created for the configured application in the alert.
Looking at the email you may want to remove the header "Anypoint Platform Alert Notification" from the email.
To remove the header, you need to send HTML content in the message field of the create notification operation in step 1.
You can create an HTML template and use a parse-template to populate all the fields and pass it in the message field of the create notification operation. Refer parse template documentation:
https://docs.mulesoft.com/mule-runtime/4.3/parse-template-reference
Limitations
- Custom application notification is available only for the cloudhub applications.
- Rate limiting on the Cloudhub APIs. Refer the documentation:
https://docs.mulesoft.com/runtime-manager/alerts-on-runtime-manager#rate-limits-on-alerts
Opinions expressed by DZone contributors are their own.
Comments