Track merged conversations
Last Update: Oct 2024 • Est. Read Time: 5 MINIf your users are assigned to a permission set that allows them to merge or combine separate conversations into one, you may be interested in tracking these conversation merges for reporting or data analysis. You can use a workflow to perform this automated task.
Who can access this feature? | |
User types | Admins can access the Workflows and API Keys pages. |
In this article
- Prerequisites
- Create an API key
- Create the workflow
- Add the workflow JSON
- Add the API key to the workflow
- Customize the workflow
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.
- Create an API key.
- When setting up your new API key, assign it with the roles
org.user.conversation.read
andorg.permission.conversation.read
. - 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 assign conversations.
- Go to Settingsand select Platform > Workflows.
- Select Add Workflow > Custom Workflow.
- The New Workflow modal will appear. Fill out the Workflow Title. Add a description to help remember what function this workflow serves in the future.
- Leave the callable workflow option turned off.
- 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.
- In the Workflow Editor, open the Workflow Optionsmenu and select Edit Workflow JSON.
- A modal appears where you can edit the code for this workflow. Select and delete all the current JSON code.
- 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": "track-and-add-note-on-merged-conversations", "steps": [ { "transitions": [ { "target": "pEDKbR89t", "condition": { "op": "true", "values": [ true ] } } ], "errorCases": [], "id": "AEPHnMx4d", "action": "kustomer.regex-match.generic", "params": { "testString": "/#steps.-4j4buTAQ.response.body.data.links.related", "regex": "\\/v1\\/conversations\\/(.*)" }, "meta": { "displayName": "Get Target Conversation's ID" }, "appVersion": "kustomer-^1.9.2" }, { "transitions": [ { "target": "JlLkAL2-B", "condition": { "op": "true", "values": [ true ] } } ], "errorCases": [], "id": "pEDKbR89t" }, { "transitions": [ { "target": "iBNOl5EXz", "condition": { "op": "true", "values": [ true ] } } ], "errorCases": [], "id": "JlLkAL2-B", "action": "kustomer.user.find-by-id", "appVersion": "kustomer-^1.9.2", "params": { "id": "/#steps.1.modifiedBy" }, "meta": { "displayName": "Find User who Merged the Conversations" } }, { "transitions": [], "errorCases": [], "id": "iBNOl5EXz", "action": "kustomer.note.create", "params": { "conversation": "/#steps.AEPHnMx4d.captures", "body": "Conversation {{{steps.1.id}}} has been merged to this conversation by **{{{steps.JlLkAL2-B.name}}}**." }, "meta": { "displayName": "Create Merge Note on Target Conversation" }, "appVersion": "kustomer-^1.9.2" }, { "transitions": [ { "target": "AEPHnMx4d", "condition": { "op": "and", "values": [ { "op": "exists", "values": [ "/#steps.-4j4buTAQ.response.body.data.links.related", "" ] }, { "op": "neq", "values": [ "/#steps.-4j4buTAQ.response.body.data.links.related", "null" ] } ] }, "meta": { "name": "Parent / Target Conversation Exists" } } ], "errorCases": [], "id": "-4j4buTAQ", "action": "kustomer.rest-api.json", "params": { "uri": "https://api.kustomerapp.com/v1/conversations/{{{steps.1.id}}}", "method": "GET", "headers": { "Authorization": "Bearer", "Content-Type": "application/json" }, "json": true }, "meta": { "displayName": "Get Merged (Soft-Deleted) Conversation's Data" }, "appVersion": "kustomer-^1.9.2" } ], "trigger": { "transitions": [ { "target": "-4j4buTAQ", "condition": { "op": "eq", "values": [ "/#steps.1.changes.attributes.deleted.after", "true" ] }, "meta": { "name": "Is Merged (Soft-Deleted)" } } ], "eventName": "kustomer.conversation.update", "id": "1", "appVersion": "kustomer-^1.9.2" } }
The workflow will look like this:
Add the API key to the workflow
- Reopen the Workflow Optionsmenu and select Workflow Variables.
- 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.
- Save the variable, select Close to exit the workflow editor, and save the updated workflow.
Customize the workflow
- In Step 2 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.
- 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.
- In the same step (Step 2), go to Uri (string) field and add your your Kustomer subdomain before
.api
to complete the API endpoint. For example, if your Kustomer URL isacme-inc.kustomer.com
, your Uri (string) would begin withhttps://acme-inc.api.kustomerapp
. - 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.