This topic provides a worked example of how to set up a Notification to be triggered by an Event only if the specific conditions of a rule defined for the Notification Configuration are satisfied:
Any Commitment updated Event where the Commitment amount drops below 10% of the original amount.
When an Event of this type occurs in the system and which satisfies this condition, a Notification will be sent to the configured destination.
You can follow the set up in three steps.
POST at https://api.m3ter.com/organizations/{orgId}/notifications/configurations/
In this example, we’ve set up a rule for triggering a Notification based on a configuration.commitment.updated Event, which includes a calculation referencing Event Fields to define the precise conditions for triggering the Notification. The calculation means the Notification will be triggered when the amount spent from the commitment drops below 10% of the total amount.
1{2"name": "Commitment has under 10% remaining",3"description": "Commitment amount fell below 10%",4"eventName": "configuration.commitment.updated",5"calculation": "(new.amountSpent >= ((new.amount*100)/90))6AND ((old.amountSpent <= ((old.amount*100)/90)) OR (old.amountSpent == null))",7"code" : "under_10_percent_",8"active": true9}
Note: The response schema for this call returns a unique “id” for the notification rule we’ve set up
POST at: https://api.m3ter.com/organizations/{orgId}/integrationdestinations/webhooks
1{2"url":"https://xbmnbkwece.execute-api.eu-west-2.amazonaws.com/dev/send_email"3"version": 1,4"credentials": {5"version": 1,6"type": "M3TER_SIGNED_REQUEST",7"apiKey": "apiKey",8"secret": "some secret"9}10}
With this call, credentials are done in the same call as the integration destination. In the response schema, the unique “id” for Integration Destination is returned.
POST at: https://api.m3ter.com/organizations/{orgId}/integrationconfigs
1{2"entityType": "Notification",3"entityId": "id of the notification rule",4"destination": "Webhook",5"destinationId": "id of the destination",6"configData": {},7"credentials": {8"type" : "M3TER_SIGNED_REQUEST"9}10}
For this call: