Skip to content

Instantly share code, notes, and snippets.

@mehranabi
Created October 11, 2024 14:01
Show Gist options
  • Save mehranabi/93e9b94677be3636dc7a26aa31b6e65f to your computer and use it in GitHub Desktop.
Save mehranabi/93e9b94677be3636dc7a26aa31b6e65f to your computer and use it in GitHub Desktop.
Webform Submissions Notification Workflow
{
"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