See related
No related articles

Reroute conversations from the default queue

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

In Queues and Routing, your default queue acts as a catch-all for conversations that do not match any of your queue rules. It has a queue priority of 1 and cannot be edited or deleted.

In some cases, automations — like business rules, workflows, or APIs — might run after a conversation has already been routed, and those automations are critical for the conversation landing in the right queue. In this scenario, you can use a workflow to clear the queue assignment on conversations that go to the default queue and requeue them.

Who can access this feature?
User typesAdmins and users with permissions to access workflows and API keys.


In this article

Prerequisites

Before following this guide, you should already be comfortable with the basics of using workflows. Workflows overview

We also recommend being familiar with creating API keys and adding workflow variables.

Create an API key

First, you'll need to set up the API key to use with the workflow.

  1. Create an API key.
  2. When setting up your new API key, assign it with the roles org.permission.conversation.update and org.user.conversation.write.
  3. Then, keep the token in a secure location to use later in this guide.

Create the workflow

Next, you'll set up the workflow to reroute conversations.

  1. Go to Settingsand select Platform > Workflows.
  2. Select Add Workflow > Custom Workflow.
  3. The New Workflow modal will appear. Fill out the Workflow Title. You can leave the Description field blank because the code snippet below will provide this for you.
  4. Leave the callable workflow option turned off.
  5. Select Create to save the workflow. You'll be taken to the Workflow Editor where the workflow can be customized.

Add the workflow JSON

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

  1. In the Workflow Editor, open the Workflow Optionsmenu and select Edit Workflow JSON.
  2. A modal appears where you can edit the code for this workflow. Select and delete all the current JSON code.
  3. Copy the below code block, and paste it into the JSON text field in your Workflow Editor. Then, select Update to save the changes to the workflow and dismiss the JSON editor.
{
  "description": "",
  "name": "reroute-conversations-from-default-queue",
  "steps": [
    {
      "transitions": [
        {
          "target": "6g9Dokv3y",
          "condition": {
            "op": "neq",
            "values": [
              "/#steps.1.status",
              "done"
            ]
          },
          "meta": {
            "name": "Conversation is Open or Snoozed"
          }
        }
      ],
      "errorCases": [],
      "id": "TSL_jNt24"
    },
    {
      "transitions": [],
      "errorCases": [],
      "id": "6g9Dokv3y",
      "action": "kustomer.rest-api.json",
      "params": {
        "uri": "https://api.kustomerapp.com/v1/conversations/{{steps.1.id}}",
        "method": "PATCH",
        "data": {
          "queue": {
            "id": null
          },
          "assignedUsers": []
        },
        "headers": {
          "Authorization": "Bearer",
          "Content-Type": "application/json"
        },
        "json": true
      },
      "meta": {
        "displayName": "Unset Queue to Reroute Conversation"
      },
      "appVersion": "kustomer-^1.9.2"
    },
    {
      "transitions": [
        {
          "target": "TSL_jNt24",
          "condition": {
            "op": "dne",
            "values": [
              "/#steps.1.assignedUsers.0",
              ""
            ]
          },
          "meta": {
            "name": "Conversation is Unassigned"
          }
        }
      ],
      "errorCases": [],
      "id": "i6HWiIZeM"
    }
  ],
  "trigger": {
    "transitions": [
      {
        "target": "i6HWiIZeM",
        "condition": {
          "op": "contains",
          "values": [
            "/#steps.1.queue",
            null
          ]
        },
        "meta": {
          "name": "Conversation Routed to Default Queue"
        }
      }
    ],
    "eventName": "kustomer.conversation.update",
    "id": "1",
    "appVersion": "kustomer-^1.9.2"
  }
}

The workflow will look like this:


Add the API key to the workflow

  1. Reopen the  Workflow Optionsmenu and select Workflow Variables.
  2. Add the saved token from the API key you created earlier as a workflow variable. Name the workflow variable as desired and add the token in the Value field.
  3. Save the variable, select Close to exit the workflow editor, and save the updated workflow.

Customize the workflow

  1. In Step 4 of the workflow, select the key icon in the REST API JSON action step to access the workflow variable saved, and copy the workflow variable.
  2. Add a single space after Bearer in the Headers section, and paste the copied value which is the API token needed for authorization. Set the JSON (boolean) field to true.
  3. In the first condition called Conversation Routed to Default Queue, select the Default Queue as the queue that the conversation should be in.
  4. If there are any other changes to the workflow that you'd like to make, do so now. When you're finished, Save all and other workflow changes, and use the toggle to activate the workflow.