Pass state
A Pass state passes the state's input to its output. You can also add arbitrary data to the output.
You typically use a Pass state as a placeholder for a state you haven't written yet. You can also use a Pass state to add mock data to a ZIS flow. This is often useful for testing or troubleshooting. For examples, see Mocking a built-in action and Mocking a custom action.
In production, you can use a Pass state to append data to a reference path. This can reduce the complexity of your flow and help you avoid passing large JSON objects to Transform actions. For an example, see Adding data to a reference path.
"Mock.GetTicket": {"Type": "Pass","Result": {"id": 35436,"subject": "Help, my printer is on fire!"},"ResultPath": "$.ticket","Next": "MyNextStep"}
Supported properties
In addition to common state
properties,
a Pass state supports the Result property.
| Name | Type | Mandatory | Description |
|---|---|---|---|
| Result | object | false | Output for the state |
Mocking a built-in action
The following Pass state mocks the output of a LoadConfig action. You can use the state to test a ZIS flow before building a Zendesk app that lets admins specify the config settings.
"Mock.LoadConfigData": {"Type": "Pass","Result": {"channel": "#zendesk-tickets","priority": "urgent"},"ResultPath": "$.settings","Next": "MyNextStep"}
Mocking a custom action
The following Pass state mocks the output of a ZIS custom action. You can use the state to test a ZIS flow without defining the action or making an API request.
"Mock.InitiateRefund": {"Type": "Pass","Result": {"transaction_id": 54321,"transaction_value": "99.01","transaction_state": "pending_approval"},"ResultPath": "$.refund_details","Next": "MyNextStep"}
Adding data to a reference path
The following ZIS bundle's job spec listens for the Comment Created event. When the event occurs, the bundle's ZIS flow retrieves a HTML-formatted version of the event's comment body. It then posts the HTML body to an external URL.
The bundle's flow includes a Pass state. The state appends the event's comment
id to a List
Comments
response object in the $.fetched_comments path.
This setup lets the flow's Transform action access both the event's comment id and the comments object without processing the entire $ object. By processing a smaller JSON object, the Transform action runs more efficiently.
{"zis_template_version": "2019-10-14","name": "Send webhook when ticket comment is added","description": "Send webhook when ticket comment is added","resources": {"fetch_ticket_comments": {"type": "ZIS::Action::Http","properties": {"name": "fetch_ticket_comments","definition": {"method": "GET","path": "/api/v2/tickets/{{$.ticket_id}}/comments.json","connectionName": "zendesk"}}},"post_webhook": {"type": "ZIS::Action::Http","properties": {"name": "post_webhook","definition": {"method": "POST","url": "EXTERNAL_TARGET_URL","requestBody": {"text.$": "$.message"}}}},"Flow": {"type": "ZIS::Flow","properties": {"name": "PostWebhookFlow","definition": {"StartAt": "fetch_comments","States": {"fetch_comments": {"Type": "Action","ActionName": "zis:INTEGRATION:action:fetch_ticket_comments","Parameters": {"ticket_id.$": "$.input.ticket_event.ticket.id"},"ResultPath": "$.fetched_comments","Next": "pass.store_this_comment_id"},"pass.store_this_comment_id": {"Type": "Pass","Result": {"this_id.$": "$.input.ticket_event.comment.id"},"ResultPath": "$.fetched_comments","Next": "transform.fetch_this_comment"},"transform.fetch_this_comment": {"Type": "Action","ActionName": "zis:common:transform:Jq","Parameters": {"data.$": "$.fetched_comments","expr": ".this_id as $my_id | .comments[] | select(.id == $my_id).html_body"},"ResultPath": "$.fetched_comments.this_comment","Next": "post_webhook"},"post_webhook": {"Type": "Action","ActionName": "zis:INTEGRATION:action:post_webhook","Parameters": {"message.$": "$.fetched_comments.this_comment"},"ResultPath": "$.posted_webhook","End": true}}}}},"JobSpec": {"type": "ZIS::JobSpec","properties": {"name": "TicketCommentAddedJobSpec","event_source": "support","event_type": "ticket.CommentAdded","flow_name": "zis:INTEGRATION:flow:PostWebhookFlow"}}}}
Before using the bundle, replace the "EXTERNAL_TARGET_URL" placeholder with an external target URL, such as an endpoint URL you obtained from RequestBin. Replace "INTEGRATION" with your ZIS integration key.