Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createThread threadFields documentation #49

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion _snippets/graphql/create-thread.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ mutation createThread($input: CreateThreadInput!) {
title
previewText
priority
threadFields {
id
key
type
stringValue
booleanValue
}
}
error {
message
Expand Down Expand Up @@ -44,7 +51,26 @@ mutation createThread($input: CreateThreadInput!) {
}
}
],
"labelTypeIds": ["lt_01HB924PME9C0YWKW1N4AK3BZA"]
"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,
// }],
}
}
```
25 changes: 24 additions & 1 deletion _snippets/typescript-sdk/create-thread.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```ts
import { PlainClient } from '@team-plain/typescript-sdk';
import { PlainClient, ThreadFieldSchemaType } from '@team-plain/typescript-sdk';

const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });

Expand All @@ -25,6 +25,29 @@ const res = await client.createThread({
// Label types are created in settings where you can also copy
// their ID.
labelTypeIds: ['lt_01HB924PME9C0YWKW1N4AK3BZA'],

// Thread fields are created in settings where you can also copy
// their key.
threadFields: [
{
key: 'my_string_field',
type: ThreadFieldSchemaType.String,
stringValue: 'any value',
},
],

// You can also set other thread field types like boolean or enum.
// threadFields: [{
// key: 'my_enum_field',
// type: ThreadFieldSchemaType.Enum,
// stringValue: 'any specified value',
// }]
//
// threadFields: [{
// key: 'my_bool_field',
// type: ThreadFieldSchemaType.Bool,
// booleanValue: true,
// }],
});

if (res.error) {
Expand Down
3 changes: 3 additions & 0 deletions api-reference/graphql/threads/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ To create a thread you need a `customerId`. You can get a customer id by [creati
- `thread:create`
- `thread:edit`
- `thread:read`
- `threadField:create`
- `threadField:update`
- `threadField:read`

<Snippet file="typescript-sdk/create-thread.mdx" />

Expand Down
Loading