See related
No related articles

Resolve snoozed conversations with workflows

Last Update: Oct 2024 • Est. Read Time: 12 MIN
To check plan availability, see the pricing page.

While your users may change conversation statuses and use the snooze status correctly when awaiting a customer's reply, you may find a number of your snoozed conversations still not receiving a customer response after an extended period of time.

Depending on your team's needs, you may want to send a final outgoing message to these customers, and/or automatically mark these conversations done after a certain time. You can set up Kustomer workflows to automate either or both these processes.

Who can access this feature?
User typesAdmins can access the Workflows page.


In this article:

Prerequisites

Before following this guide, we recommend that you already be comfortable with the basics of using workflows: Workflows overview

You should also be familiar with creating callable scheduled workflows, API keys, and adding workflow variables.

Create the callable workflow

  1. Go to Settingsand select Platform > Workflows.
  2. Select Add Workflow > Custom Workflow.
  3. The New Workflow modal will appear. Fill out the title. You can leave the description field blank because the code snippet below will provide this for you. Toggle Callable Workflow on.
  4. Select Create to save the workflow.
  5. When the following window appears, select Cancel and close it. You'll add the workflow JSON code directly in the next step.

Enter the callable workflow JSON code

Use the Workflow Editor to paste in the workflow code supplied below. This JSON code will take care of most of the workflow creation.

Note: This workflow uses Kustomer system email (Postmark) to send the final email message. If you are using the Gmail integration, follow the steps in the next section Workflow variation for Gmail integration.

  1. In the Workflow Editor, use the Workflow Optionsto select Edit Workflow JSON.
  2. A modal appears where you can edit the code for this workflow directly. Select and delete all the current JSON code.
  3. Copy the following code block, and paste it into the JSON text field in your Workflow Editor. Then, select Update to dismiss the JSON editor and save the changes to the workflow.
    {
      "description": "",
      "name": "send-final-message-and-mark-snoozed-conversation-done",
      "steps": [
        {
          "transitions": [
            {
              "target": "cA3N4BBWS",
              "condition": {
                "op": "true",
                "values": [
                  true
                ]
              }
            }
          ],
          "errorCases": [],
          "id": "QoZgm-XHR"
        },
        {
          "transitions": [
            {
              "target": "N9f5GJx9D",
              "condition": {
                "op": "eq",
                "values": [
                  "/#steps.mr6a_zgjB.status",
                  "snoozed"
                ]
              },
              "meta": {
                "name": "Still Snoozed"
              }
            }
          ],
          "errorCases": [],
          "id": "cA3N4BBWS"
        },
        {
          "transitions": [
            {
              "target": "ZApw9lh_E",
              "condition": {
                "op": "eq",
                "values": [
                  "/#steps.1.LastMessageIn",
                  "/#steps.mr6a_zgjB.lastMessageIn.id"
                ]
              },
              "meta": {
                "name": "Customer Last Message is the Same"
              }
            }
          ],
          "errorCases": [],
          "id": "N9f5GJx9D"
        },
        {
          "transitions": [
            {
              "target": "TNb5wj4v2",
              "condition": {
                "op": "and",
                "values": [
                  {
                    "op": "gt",
                    "values": [
                      "/#fn:parseInt,steps.ZApw9lh_E.match",
                      "6"
                    ]
                  },
                  {
                    "op": "neq",
                    "values": [
                      "/#steps.mr6a_zgjB.snooze.status",
                      "canceled"
                    ]
                  }
                ]
              },
              "meta": {
                "name": "Conversation Still Snoozed Until Customer Replies"
              }
            }
          ],
          "errorCases": [],
          "id": "ZApw9lh_E",
          "action": "kustomer.regex-match.generic",
          "params": {
            "testString": "{{dateDiff \"months\" from=steps.mr6a_zgjB.snooze.statusAt to=steps.mr6a_zgjB.snooze.time}}",
            "regex": ".*"
          },
          "meta": {
            "displayName": "Check Snooze Expiry"
          },
          "appVersion": "kustomer-^1.9.2"
        },
        {
          "transitions": [
            {
              "target": "01-92dCVs",
              "condition": {
                "op": "true",
                "values": [
                  true
                ]
              }
            }
          ],
          "errorCases": [],
          "id": "TNb5wj4v2"
        },
        {
          "transitions": [
            {
              "target": "ENfQ9RGA4",
              "condition": {
                "op": "true",
                "values": [
                  true
                ]
              },
              "meta": {
                "name": "Last Outbound Message is the Same"
              }
            }
          ],
          "errorCases": [],
          "id": "01-92dCVs"
        },
        {
          "transitions": [
            {
              "target": "oYPlEahZh",
              "condition": {
                "op": "exists",
                "values": [
                  "/#steps.ENfQ9RGA4.id",
                  ""
                ]
              },
              "meta": {
                "name": "Customer Found"
              }
            }
          ],
          "errorCases": [],
          "id": "ENfQ9RGA4",
          "action": "kustomer.customer.find",
          "params": {
            "identifier": "/#steps.mr6a_zgjB.customer"
          },
          "meta": {
            "displayName": "Find Customer ID"
          },
          "appVersion": "kustomer-^1.9.2"
        },
        {
          "transitions": [
            {
              "target": "_-MbiSxrg",
              "condition": {
                "op": "exists",
                "values": [
                  "/#steps.ENfQ9RGA4.emails.0.email",
                  ""
                ]
              },
              "meta": {
                "name": "Customer Has Email Address"
              }
            }
          ],
          "errorCases": [],
          "id": "oYPlEahZh"
        },
        {
          "transitions": [
            {
              "target": "xRzzrUzk_",
              "condition": {
                "op": "true",
                "values": [
                  true
                ]
              }
            }
          ],
          "errorCases": [],
          "id": "_-MbiSxrg"
        },
        {
          "transitions": [
            {
              "target": "pQrO1j0-E",
              "condition": {
                "op": "true",
                "values": [
                  true
                ]
              }
            }
          ],
          "errorCases": [],
          "id": "xRzzrUzk_",
          "action": "kustomer.app.postmark.message.send",
          "params": {
            "customer": "/#steps.ENfQ9RGA4.id",
            "conversation": "/#steps.mr6a_zgjB.id",
            "from": "your@emailaddress.here",
            "to": [
              "/#steps.ENfQ9RGA4.emails.0.email"
            ]
          },
          "appVersion": "postmark-^1.1.11",
          "meta": {
            "displayName": "Send Message"
          }
        },
        {
          "transitions": [],
          "errorCases": [],
          "id": "pQrO1j0-E",
          "action": "kustomer.conversation.update",
          "params": {
            "id": "/#steps.mr6a_zgjB.id",
            "status": "done"
          },
          "appVersion": "kustomer-^1.9.2",
          "meta": {
            "displayName": "Mark Conversation Done"
          }
        },
        {
          "transitions": [
            {
              "target": "QoZgm-XHR",
              "condition": {
                "op": "exists",
                "values": [
                  "/#steps.mr6a_zgjB.id",
                  ""
                ]
              },
              "meta": {
                "name": "Conversation Found"
              }
            }
          ],
          "errorCases": [],
          "id": "mr6a_zgjB",
          "action": "kustomer.conversation.find-by-id",
          "params": {
            "id": "/#steps.1.ConversationId"
          },
          "meta": {
            "displayName": "Find Conversation ID"
          },
          "appVersion": "kustomer-^1.9.2"
        }
      ],
      "trigger": {
        "transitions": [
          {
            "target": "mr6a_zgjB",
            "condition": {
              "op": "true",
              "values": [
                true
              ]
            }
          }
        ],
        "id": "1",
        "callable": true,
        "schema": {
          "properties": {
            "ConversationId": {
              "type": "string"
            },
            "LastMessageIn": {
              "type": "string"
            }
          },
          "required": [
            "ConversationId",
            "LastMessageIn"
          ]
        },
        "eventName": "kustomer.workflow.63105cabcee4d3e0d70fb2f0.call"
      }
    }
  4. The workflow will look like this:
  5. Update the Send Message step in the workflow to add your email address that the final message should send from, as well as the subject, body, and other fields you would like to modify.

Workflow variation for Gmail integration

If using our Gmail integration, change the Send Message step in the workflow to a Gmail > Send Message action instead, and update the required and any optional fields. 

Change the workflow step's Action App from Postmark to GmailUpdate the fields in the modified action step and save the workflow.

Workflow variation to send a chat message

Change the workflow step's Action App from Postmark to Chat. Update the fields in the modified action step and save the workflow.

Workflow variation to send an SMS

To use this variation, the text message (SMS) channel must be set up. Make sure your customers have a number in the Phone Numbers field in their profile to send the SMS to.

  1. Change the workflow step's Action App from Postmark to Kustomer. Then, select the Action Event: Rest API JSON.
  2. In the URI string field, add https://<your_company>.api.kustomerapp.com/v1/customers/{{steps.ENfQ9RGA4.id}}/drafts.
  3. Under Method, use POST.
  4.  Add the following code in the Optional Fields > Data field. Replace the body value with your preferred text, and the from value with your company's SMS number.
    {
      "body": "your text message",
      "to": "/#steps.ENfQ9RGA4.phones.0.phone",
      "from": "your SMS number",
      "sendAt": "{{{date 'day' count=0}}}",
      "conversation": "/#steps.mr6a_zgjB.id",
      "channel": "sms"
    }
  5. Create an API key in Settings under Security > API Keys with the roles org.permission.draft.create and org.user.draft.write. Copy and save the token for use in the next step.

  6. Go back to the Workflow Editor, and open the Workflow Optionsmenu to select Workflow Variables. Add the saved token from the API key you created earlier as a workflow variable. Name the workflow variable and add the token in the Value field. Save and exit the workflow editor.
  7. Select Step 12: Rest API JSON of the workflow, and select the key iconin the Headers field to access and copy the workflow variable saved. Add just one space after Bearer in the Headers field and paste the copied API token.
  8. Finally, set the JSON (boolean) field to true. The SMS action step is now complete and should look like below.
  9. Save all the changes and activate the workflow to send the SMS to customers and mark the conversation done.

7. Save all the changes and activate the workflow to send the SMS to customers and mark the conversation done.

Create the scheduler workflow

It's now time to create the scheduler workflow to trigger your completed callable workflow based on specific conditions.

  1. Go to Settings and select Platform > Workflows.
  2. Select Add Workflow > Custom Workflow.
  3. Fill out the Workflow Title. You can leave the Description field blank because the code snippet below will provide this for you.
  4. Select Create to save the workflow.
  5. In the Workflow Editor, use the Workflow Options menu to select Edit Workflow JSON.
  6. A modal appears where you can edit the code for this workflow directly. Select and delete all the current JSON code.
  7. Copy the following code block, and paste it into the JSON text field in your Workflow Editor. Then, select Update to dismiss the JSON editor and save the changes to the workflow.
    {
      "description": "Schedules snoozed conversations to be updated and marked done if not updated after a specific time.",
      "name": "scheduler-for-snoozed-conversations",
      "steps": [
        {
          "transitions": [
            {
              "target": "O21wMsmRa",
              "condition": {
                "op": "and",
                "values": [
                  {
                    "op": "gt",
                    "values": [
                      "/#fn:parseInt,steps.rKSS-fxFU.match",
                      "6"
                    ]
                  },
                  {
                    "op": "neq",
                    "values": [
                      "/#steps.1.snooze.status",
                      "canceled"
                    ]
                  }
                ]
              },
              "meta": {
                "name": "Conversation is Snoozed Until Customer Replies"
              }
            }
          ],
          "errorCases": [],
          "id": "rKSS-fxFU",
          "action": "kustomer.regex-match.generic",
          "params": {
            "testString": "{{dateDiff \"months\" from=steps.1.changes.attributes.snooze.after.statusAt to=steps.1.changes.attributes.snooze.after.time}}",
            "regex": ".*"
          },
          "meta": {
            "displayName": "Check Snooze Expiry"
          },
          "appVersion": "kustomer-^1.9.2"
        },
        {
          "transitions": [
            {
              "target": "w3fWxkb6c",
              "condition": {
                "op": "exists",
                "values": [
                  "/#steps.O21wMsmRa.id",
                  ""
                ]
              },
              "meta": {
                "name": "Found Conversation"
              }
            }
          ],
          "errorCases": [],
          "id": "O21wMsmRa",
          "action": "kustomer.conversation.find-by-id",
          "params": {
            "id": "/#steps.1.id"
          },
          "meta": {
            "displayName": "Find Conversation ID"
          },
          "appVersion": "kustomer-^1.9.2"
        },
        {
          "transitions": [
            {
              "target": "fCxXAcItt",
              "condition": {
                "op": "exists",
                "values": [
                  "/#steps.w3fWxkb6c.id",
                  ""
                ]
              },
              "meta": {
                "name": "Last Inbound Customer Message Found"
              }
            }
          ],
          "errorCases": [],
          "id": "w3fWxkb6c",
          "action": "kustomer.message.find-by-id",
          "params": {
            "id": "/#steps.O21wMsmRa.lastMessageIn.id"
          },
          "meta": {
            "displayName": "Find Last Customer Message"
          },
          "appVersion": "kustomer-^1.9.2"
        },
        {
          "transitions": [],
          "errorCases": [],
          "id": "fCxXAcItt",
          "action": "kustomer.app.scheduler.schedule-workflow",
          "params": {
            "runAt": {
              "value": 86400,
              "type": "relative"
            }
          },
          "appVersion": "scheduler-^1.0.1"
        }
      ],
      "trigger": {
        "transitions": [
          {
            "target": "rKSS-fxFU",
            "condition": {
              "op": "and",
              "values": [
                {
                  "op": "eq",
                  "values": [
                    "/#steps.1.changes.attributes.status.after",
                    "snoozed"
                  ]
                },
                {
                  "op": "eq",
                  "values": [
                    "/#steps.1.changes.attributes.snooze.after.status",
                    "scheduled"
                  ]
                },
                {
                  "op": "neq",
                  "values": [
                    "/#steps.1.changes.attributes.snooze.before.status",
                    "scheduled"
                  ]
                },
                {
                  "op": "neq",
                  "values": [
                    "/#steps.1.changes.attributes.status.before",
                    "snoozed"
                  ]
                }
              ]
            },
            "meta": {
              "name": "Conversation is Snoozed"
            }
          }
        ],
        "eventName": "kustomer.conversation.update",
        "id": "1",
        "appVersion": "kustomer-^1.9.2",
        "meta": {
          "displayName": "Conversation is Updated"
        }
      }
    }
  8. The workflow will look like this:

  9. Update Step 5: Schedule a Workflow by selecting the callable workflow you created earlier in the Workflow Title field.
  10. Under Type, select Set a Relative Time and select the time period within which you would like the callable workflow to run.
  11. Add the Required Fields, which are the parameters that your callable workflow needs before it can perform its action steps.
  12. Add any other desired customizations to the workflow before saving all changes.

You are now ready to activate both Scheduler and Callable workflows to process your snoozed conversations awaiting customer reply.