ZIS bundle: Adding a Choice state
The following bundle extends the example in Anatomy of a ZIS bundle by adding a second flow and job spec, which responds to a Ticket Status Change event. It also implements a choice state to add conditional branching to a flow.
{
"zis_template_version": "2019-10-14",
"name": "Simple Zendesk-Slack integration",
"description": "React to Ticket events in ZIS with a Slack message",
"resources": {
"slack.post_simple_message": {
"type": "ZIS::Action::Http",
"properties": {
"name": "slack.post_simple_message",
"definition": {
"method": "POST",
"url.$": "https://hooks.slack.com/services/{{$.path}}",
"requestBody": {
"text.$": "$.slack_message"
}
}
}
},
"react_to_ticket_commentadded_flow": {
"type": "ZIS::Flow",
"properties": {
"name": "react_to_ticket_commentadded_flow",
"definition": {
"StartAt": "PostCommentAddedMessageToSlack",
"States": {
"PostCommentAddedMessageToSlack": {
"Type": "Action",
"ActionName": "zis:{integration_name}:action:slack.post_simple_message",
"Parameters": {
"path": "{slack_token}",
"slack_message.$": "A new comment: {{$.input.ticket_event.comment.body}}"
},
"End": true
}
}
}
}
},
"react_to_ticket_statuschanged_flow": {
"type": "ZIS::Flow",
"properties": {
"name": "react_to_ticket_statuschanged_flow",
"definition": {
"StartAt": "CheckTicketStatus",
"States": {
"CheckTicketStatus": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.input.ticket_event.current",
"StringEquals": "solved",
"Next": "PostStatusSolvedMessageToSlack"
}
],
"Default": "StatusNotSolved"
},
"PostStatusSolvedMessageToSlack": {
"Type": "Action",
"ActionName": "zis:{integration_name}:action:slack.post_simple_message",
"Parameters": {
"path": "{slack_token}",
"slack_message": "High five team, another customer issue solved!"
},
"End": true
},
"StatusNotSolved": {
"Type": "Succeed",
"Message": "Nothing to see here. Status has changed but has not become Solved."
}
}
}
}
},
"react_to_ticket_commentadded_job_spec": {
"type": "ZIS::JobSpec",
"properties": {
"name": "react_to_ticket_commentadded_job_spec",
"event_source": "support",
"event_type": "ticket.CommentAdded",
"flow_name": "zis:{integration_name}:flow:react_to_ticket_commentadded_flow"
}
},
"react_to_ticket_statuschanged_job_spec": {
"type": "ZIS::JobSpec",
"properties": {
"name": "react_to_ticket_statuschanged_job_spec",
"event_source": "support",
"event_type": "ticket.StatusChanged",
"flow_name": "zis:{integration_name}:flow:react_to_ticket_statuschanged_flow"
}
}
}
}
Replace the following placeholders with your own values:
{integration_name}
with the name of your integration{slack_token}
should be replaced with the token portion of a Slack webhook URL https://hooks.slack.com/services/{slack_token}.