Created
October 11, 2024 14:01
-
-
Save mehranabi/93e9b94677be3636dc7a26aa31b6e65f to your computer and use it in GitHub Desktop.
Webform Submissions Notification Workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "Webform Submission Notification", | |
"initial": "Start", | |
"triggers": { | |
"entity": [ | |
{ | |
"action": "create", | |
"label": "WebformSubmission" | |
} | |
] | |
}, | |
"states": { | |
"Start": { | |
"always": [ | |
{ | |
"target": "GetSettings", | |
"cond": { | |
"type": "conditions", | |
"condition": { | |
"not": [ | |
{ | |
"empty": [ | |
"{{/event/context/id}}" | |
] | |
} | |
] | |
} | |
} | |
}, | |
{ | |
"target": "Final" | |
} | |
] | |
}, | |
"GetSettings": { | |
"invoke": { | |
"src": "graphql", | |
"data": { | |
"gql": "query getWebform($id: String!) { Webform(id: $id) { id, data } }", | |
"variables": { | |
"id": "{{/event/context/id}}" | |
}, | |
"system": true | |
}, | |
"meta": { | |
"description": "Get Webforms data to extract notification settings", | |
"attachContext": "/settings" | |
}, | |
"onDone": "SendNotification", | |
"onError": "Error" | |
} | |
}, | |
"SendNotification": { | |
"invoke": { | |
"src": "inbox", | |
"data": { | |
"message_from": "{{/event/actor/id}}", | |
"message_to": [ | |
"{{$.data.settings.Webform.data.settings.notificationsReceivers[0]}}" | |
], | |
"message": "A new webform submission has been created", | |
"type": "reactions.webform.type.created", | |
"entity_id": "{{/event/context/id}}", | |
"entity_type": "WebformSubmission" | |
}, | |
"onDone": "Final", | |
"onError": "Error" | |
} | |
}, | |
"Final": { | |
"type": "final" | |
}, | |
"Error": { | |
"type": "final" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment