Automations
Introduction
The Automations feature empowers you to build custom workflows through built-in Unthread actions, 3rd party integrations, and custom code.
Example use-cases for automations:
- When a password reset request comes in, send an approval to the IT manager, and once approved, call to Okta to reset their token
- When a ‼️‼️ emoji is applied, escalate the conversation to critical priority, and notify the on-call team
- When a new user joins, send automated Slack messages to onboard, and provision access to the right Google Groups
Triggering an Action
Automatically Trigger
Because Unthread can automatically track conversations, you can set up actions to be kicked off on different events.
Triggers include:
- Conversation created
- Conversation updated
- Approval request response received
- New message received
- Emoji reaction applied
Manually Trigger
You can manually trigger an automation from your dashboard to kick off actions. You’ll automatically have the context of the conversation passed into the action, and you can optionally configure additional input fields that required before the automation can be started.
Trigger via Webhooks
We’ll generate a unique URL for your automation to be kicked from a 3rd party system.
Filters
You can optionally add filters that will only start the automation if the conversation matches filters around ticket type, status, customer, assignee, and more.
Custom Code
Actions started by any of the triggers above can kick off custom code. Code by default is written in TypeScript, and will contain references to your conversations, your Unthread account, and any stored secrets (see more below).
We provide code snippets of common actions so you get the full flexibility of controlling the actions, success handling, and error handling, while also not needing to write code yourself.
Example Action: Creating Task in Jira for Critical Priority Conversations
export async function main({ input, unthreadClient }: any) {
const CRITICAL_PRIORITY = 9;
const {
conversation: {
id,
title,
priority,
initialMessage: { text },
},
} = input;
if (conversation.priority === CRITICAL_PRIORITY) {
const externalTaskRes = await unthreadClient.post(`/conversations/${id}/external-tasks`, {
title: title,
description: text,
projectId: "10000",
providerConfig: {
jiraIssueTypeName: "Task",
},
});
const externalTask = await externalTaskRes.json();
if (!externalTaskRes.ok) {
throw new Error(`Failed to create issue, status: ${externalTaskRes.status}, response: ${JSON.stringify(externalTask ?? {})}`);
}
console.log(`Created issue`, externalTask);
}
}
Storing Secrets
When making requests to 3rd party services, any API keys or sensitive information need to be encrypted rather than stored in code.
Using our Secret Management system, we’ll encrypt your secrets using Google’s 256-bit encrypted Key Management System.
Storing Persistent Data
We provide a key-value storage system to maintain a persistent store of data to be used in your custom code.
For example, if you want to send a CSAT survey if it’s been at least 1 week since the last survey, you can store and check the last survey send date from your key-value store.