Documentation Index
Fetch the complete documentation index at: https://www.plain.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Using TypeScript? Check out our GraphQL SDK for a fully typed client.
Creating a thread is useful in scenarios where you want to programmatically start a support interaction.
You can do this in many different scenarios but the most common use-cases are when a contact form is submitted or when you want to provide proactive support off the back of some event or error happening in your product.
A thread is created with an initial ‘message’ composed out of UI components. You have full control over the structure and appearance of the message in Plain.
To create a thread you need a customerId. You can get a customer id by creating the customer in Plain first.
To create a thread, you need an API key with the following permissions:
thread:create
thread:read
mutation createThread($input: CreateThreadInput!) {
createThread(input: $input) {
thread {
id
externalId
customer {
id
}
status
statusChangedAt {
iso8601
unixTimestamp
}
title
previewText
priority
threadFields {
id
key
type
stringValue
booleanValue
}
}
error {
message
type
code
fields {
field
message
type
}
}
}
}
{
"input": {
"title": "Bug Report",
"customerIdentifier": {
"customerId": "c_01H14DFQ4PDYBH398J1E99TWSS"
},
"components": [
{
"componentText": {
"text": "The login button is not working, it doesn't do anything."
}
}
],
"labelTypeIds": ["lt_01HB924PME9C0YWKW1N4AK3BZA"],
"threadFields": [
{
"key": "my_string_field",
"type": "STRING",
"stringValue": "any value"
}
]
// You can also set other thread field types like boolean or enum.
// "threadFields": [{
// "key": "my_enum_field",
// "type": "ENUM",
// "stringValue": "any specified value",
// }],
//
// "threadFields": [{
// "key": "my_bool_field",
// "type": "BOOL",
// "booleanValue": true,
// }],
}
}