From c76af82bb15a8cf479f015b463763a1780b2b769 Mon Sep 17 00:00:00 2001 From: Mathias Vagni Date: Tue, 23 Apr 2024 11:25:48 +0200 Subject: [PATCH] Add docs for thread fields (#40) * add docs for thread fields * fix formatting * make formatting consistent * fix import * lint * Update thread-fields.mdx Co-authored-by: Preslav Mihaylov * Update thread-fields.mdx Co-authored-by: Preslav Mihaylov * review feedback --------- Co-authored-by: Preslav Mihaylov --- _snippets/graphql/delete-thread-field.mdx | 24 ++++++++++ _snippets/graphql/upsert-thread-field.mdx | 45 +++++++++++++++++++ .../typescript-sdk/add-customer-to-group.mdx | 2 +- .../add-customer-to-tenants.mdx | 6 ++- _snippets/typescript-sdk/add-labels.mdx | 2 +- .../typescript-sdk/add-members-to-tier.mdx | 6 ++- _snippets/typescript-sdk/assign-thread.mdx | 6 +-- .../typescript-sdk/create-attachment-url.mdx | 4 +- .../typescript-sdk/create-customer-event.mdx | 7 +-- .../typescript-sdk/create-thread-event.mdx | 7 +-- _snippets/typescript-sdk/create-thread.mdx | 6 +-- _snippets/typescript-sdk/delete-customer.mdx | 6 +-- .../typescript-sdk/delete-thread-field.mdx | 15 +++++++ _snippets/typescript-sdk/error-handling.mdx | 2 +- _snippets/typescript-sdk/first-api-call.mdx | 2 +- _snippets/typescript-sdk/get-companies.mdx | 6 ++- .../typescript-sdk/get-customer-by-email.mdx | 8 ++-- .../typescript-sdk/get-customer-by-id.mdx | 8 ++-- _snippets/typescript-sdk/get-customers.mdx | 8 ++-- _snippets/typescript-sdk/get-tenant-by-id.mdx | 6 ++- _snippets/typescript-sdk/get-tenants.mdx | 6 ++- _snippets/typescript-sdk/get-tier-by-id.mdx | 6 ++- _snippets/typescript-sdk/get-tiers.mdx | 6 ++- .../typescript-sdk/mark-thread-as-done.mdx | 6 +-- .../typescript-sdk/mark-thread-as-todo.mdx | 6 +-- _snippets/typescript-sdk/page-info-after.mdx | 6 +-- .../remove-customer-from-groups.mdx | 6 +-- .../remove-customer-from-tenants.mdx | 2 +- _snippets/typescript-sdk/remove-labels.mdx | 2 +- .../remove-members-from-tier.mdx | 6 ++- _snippets/typescript-sdk/reply-email.mdx | 2 +- .../typescript-sdk/reply-to-response.mdx | 2 +- _snippets/typescript-sdk/reply-to-thread.mdx | 2 +- _snippets/typescript-sdk/send-email.mdx | 2 +- .../typescript-sdk/set-customer-tenants.mdx | 6 ++- _snippets/typescript-sdk/snooze-thread.mdx | 6 +-- _snippets/typescript-sdk/ui-badge.mdx | 2 +- _snippets/typescript-sdk/ui-container.mdx | 2 +- _snippets/typescript-sdk/ui-copy-button.mdx | 2 +- _snippets/typescript-sdk/ui-divider.mdx | 2 +- _snippets/typescript-sdk/ui-link-button.mdx | 2 +- _snippets/typescript-sdk/ui-plain-text.mdx | 2 +- _snippets/typescript-sdk/ui-row.mdx | 2 +- _snippets/typescript-sdk/ui-spacer.mdx | 2 +- _snippets/typescript-sdk/ui-text.mdx | 2 +- _snippets/typescript-sdk/unassign-thread.mdx | 6 +-- .../update-customer-company.mdx | 6 ++- _snippets/typescript-sdk/upsert-tenant.mdx | 6 ++- .../typescript-sdk/upsert-thread-field.mdx | 20 +++++++++ .../graphql/threads/thread-fields.mdx | 33 ++++++++++++++ data-model.mdx | 2 + mint.json | 30 ++++++++----- thread-fields.mdx | 20 +++++++++ 53 files changed, 288 insertions(+), 101 deletions(-) create mode 100644 _snippets/graphql/delete-thread-field.mdx create mode 100644 _snippets/graphql/upsert-thread-field.mdx create mode 100644 _snippets/typescript-sdk/delete-thread-field.mdx create mode 100644 _snippets/typescript-sdk/upsert-thread-field.mdx create mode 100644 api-reference/graphql/threads/thread-fields.mdx create mode 100644 thread-fields.mdx diff --git a/_snippets/graphql/delete-thread-field.mdx b/_snippets/graphql/delete-thread-field.mdx new file mode 100644 index 0000000..30b6c87 --- /dev/null +++ b/_snippets/graphql/delete-thread-field.mdx @@ -0,0 +1,24 @@ +```graphql Mutation +mutation deleteThreadField($input: DeleteThreadFieldInput!) { + deleteThreadField(input: $input) { + error { + message + type + code + fields { + field + message + type + } + } + } +} +``` + +```json Variables +{ + "input": { + "threadFieldId": "tf_01HVTN2VTNYP91P5XGDQ57M2ZX" + } +} +``` diff --git a/_snippets/graphql/upsert-thread-field.mdx b/_snippets/graphql/upsert-thread-field.mdx new file mode 100644 index 0000000..5a43d32 --- /dev/null +++ b/_snippets/graphql/upsert-thread-field.mdx @@ -0,0 +1,45 @@ +```graphql Mutation +mutation upsertThreadField($input: UpsertThreadFieldInput!) { + upsertThreadField(input: $input) { + result + threadField { + id + key + type + threadId + stringValue + booleanValue + isAiGenerated + createdAt { + iso8601 + } + updatedAt { + iso8601 + } + } + error { + message + type + code + fields { + field + message + type + } + } + } +} +``` + +```json Variables +{ + "input": { + "identifier": { + "threadId": "th_01HVNWFJS395XVPPBJNE6A8BHP", + "key": "product_area" + }, + "type": "STRING", + "stringValue": "security" + } +} +``` diff --git a/_snippets/typescript-sdk/add-customer-to-group.mdx b/_snippets/typescript-sdk/add-customer-to-group.mdx index e53328f..83a93ac 100644 --- a/_snippets/typescript-sdk/add-customer-to-group.mdx +++ b/_snippets/typescript-sdk/add-customer-to-group.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/add-customer-to-tenants.mdx b/_snippets/typescript-sdk/add-customer-to-tenants.mdx index 940d439..f5411e7 100644 --- a/_snippets/typescript-sdk/add-customer-to-tenants.mdx +++ b/_snippets/typescript-sdk/add-customer-to-tenants.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.addCustomerToTenants({ customerIdentifier: { // You can use the customer email diff --git a/_snippets/typescript-sdk/add-labels.mdx b/_snippets/typescript-sdk/add-labels.mdx index 2e0899d..2b6709c 100644 --- a/_snippets/typescript-sdk/add-labels.mdx +++ b/_snippets/typescript-sdk/add-labels.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/add-members-to-tier.mdx b/_snippets/typescript-sdk/add-members-to-tier.mdx index 6dbdd33..8a6651f 100644 --- a/_snippets/typescript-sdk/add-members-to-tier.mdx +++ b/_snippets/typescript-sdk/add-members-to-tier.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.addMembersToTier({ memberIdentifiers: [ { diff --git a/_snippets/typescript-sdk/assign-thread.mdx b/_snippets/typescript-sdk/assign-thread.mdx index 41552b0..0662067 100644 --- a/_snippets/typescript-sdk/assign-thread.mdx +++ b/_snippets/typescript-sdk/assign-thread.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.assignThread({ threadId: 'th_01H8H46YPB2S4MAJM382FG9423', diff --git a/_snippets/typescript-sdk/create-attachment-url.mdx b/_snippets/typescript-sdk/create-attachment-url.mdx index b963280..7b32c8c 100644 --- a/_snippets/typescript-sdk/create-attachment-url.mdx +++ b/_snippets/typescript-sdk/create-attachment-url.mdx @@ -1,7 +1,7 @@ -```tsx +```ts import { AttachmentType, PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ apiKey: 'XXX' }); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.createAttachmentUploadUrl({ customerId: 'c_XXXXXXXXXXXXXXXXXXXXXXXXXX', diff --git a/_snippets/typescript-sdk/create-customer-event.mdx b/_snippets/typescript-sdk/create-customer-event.mdx index 8b18e72..bd81ecd 100644 --- a/_snippets/typescript-sdk/create-customer-event.mdx +++ b/_snippets/typescript-sdk/create-customer-event.mdx @@ -1,10 +1,7 @@ -```tsx +```ts import { PlainClient, uiComponent } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', - debug: true, -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.createCustomerEvent({ title: 'API key generated', diff --git a/_snippets/typescript-sdk/create-thread-event.mdx b/_snippets/typescript-sdk/create-thread-event.mdx index a9cf2cb..fad7f02 100644 --- a/_snippets/typescript-sdk/create-thread-event.mdx +++ b/_snippets/typescript-sdk/create-thread-event.mdx @@ -1,10 +1,7 @@ -```tsx +```ts import { PlainClient, uiComponent } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', - debug: true, -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.createThreadEvent({ title: 'API key generated', diff --git a/_snippets/typescript-sdk/create-thread.mdx b/_snippets/typescript-sdk/create-thread.mdx index 2d4bce4..843cda5 100644 --- a/_snippets/typescript-sdk/create-thread.mdx +++ b/_snippets/typescript-sdk/create-thread.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.createThread({ title: 'Bug Report', diff --git a/_snippets/typescript-sdk/delete-customer.mdx b/_snippets/typescript-sdk/delete-customer.mdx index 1ba724b..f3fcb07 100644 --- a/_snippets/typescript-sdk/delete-customer.mdx +++ b/_snippets/typescript-sdk/delete-customer.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.deleteCustomer({ customerId: 'c_01H1P4TE62AS5KZ4CZFC0578ED', diff --git a/_snippets/typescript-sdk/delete-thread-field.mdx b/_snippets/typescript-sdk/delete-thread-field.mdx new file mode 100644 index 0000000..34ed922 --- /dev/null +++ b/_snippets/typescript-sdk/delete-thread-field.mdx @@ -0,0 +1,15 @@ +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + +const res = await client.deleteThreadField({ + threadFieldId: 'tf_01HVTN2VTNYP91P5XGDQ57M2ZX', +}); + +if (res.error) { + console.error(res.error); +} else { + console.log(res.data); +} +``` diff --git a/_snippets/typescript-sdk/error-handling.mdx b/_snippets/typescript-sdk/error-handling.mdx index 3ed8ae6..96300e9 100644 --- a/_snippets/typescript-sdk/error-handling.mdx +++ b/_snippets/typescript-sdk/error-handling.mdx @@ -1,4 +1,4 @@ -```tsx {21} +```ts {21} import { PlainClient } from '@team-plain/typescript-sdk'; export async function createCustomer() { diff --git a/_snippets/typescript-sdk/first-api-call.mdx b/_snippets/typescript-sdk/first-api-call.mdx index 30ff6be..19a4290 100644 --- a/_snippets/typescript-sdk/first-api-call.mdx +++ b/_snippets/typescript-sdk/first-api-call.mdx @@ -5,7 +5,7 @@ const apiKey = 'XXX'; const email = 'XXX'; const client = new PlainClient({ - apiKey: apiKey, + apiKey, }); client.getCustomerByEmail({ email: email }).then((result) => { diff --git a/_snippets/typescript-sdk/get-companies.mdx b/_snippets/typescript-sdk/get-companies.mdx index 58897e9..98dbaa7 100644 --- a/_snippets/typescript-sdk/get-companies.mdx +++ b/_snippets/typescript-sdk/get-companies.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.getCompanies({ first: 25, }); diff --git a/_snippets/typescript-sdk/get-customer-by-email.mdx b/_snippets/typescript-sdk/get-customer-by-email.mdx index 5253d73..cb996fc 100644 --- a/_snippets/typescript-sdk/get-customer-by-email.mdx +++ b/_snippets/typescript-sdk/get-customer-by-email.mdx @@ -1,7 +1,7 @@ -```tsx -const client = new PlainClient({ - apiKey: 'XXX', -}); +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.getCustomerByEmail({ email: 'bob@example.com' }); diff --git a/_snippets/typescript-sdk/get-customer-by-id.mdx b/_snippets/typescript-sdk/get-customer-by-id.mdx index 08a5ab2..ee9c950 100644 --- a/_snippets/typescript-sdk/get-customer-by-id.mdx +++ b/_snippets/typescript-sdk/get-customer-by-id.mdx @@ -1,7 +1,7 @@ -```tsx -const client = new PlainClient({ - apiKey: 'XXX', -}); +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.getCustomerById({ customerId: 'c_01H14DFQ4PDYBH398J1E99TWSS', diff --git a/_snippets/typescript-sdk/get-customers.mdx b/_snippets/typescript-sdk/get-customers.mdx index b6b8c65..9b9cd3f 100644 --- a/_snippets/typescript-sdk/get-customers.mdx +++ b/_snippets/typescript-sdk/get-customers.mdx @@ -1,7 +1,7 @@ -```tsx -const client = new PlainClient({ - apiKey: 'XXX', -}); +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.getCustomers({ first: 50, diff --git a/_snippets/typescript-sdk/get-tenant-by-id.mdx b/_snippets/typescript-sdk/get-tenant-by-id.mdx index 742a33a..5229526 100644 --- a/_snippets/typescript-sdk/get-tenant-by-id.mdx +++ b/_snippets/typescript-sdk/get-tenant-by-id.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.getTenantById({ tenantId: 'te_123', }); diff --git a/_snippets/typescript-sdk/get-tenants.mdx b/_snippets/typescript-sdk/get-tenants.mdx index c0db8d6..4196c46 100644 --- a/_snippets/typescript-sdk/get-tenants.mdx +++ b/_snippets/typescript-sdk/get-tenants.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.getTenants({ first: 25, }); diff --git a/_snippets/typescript-sdk/get-tier-by-id.mdx b/_snippets/typescript-sdk/get-tier-by-id.mdx index a8b0a45..8e22817 100644 --- a/_snippets/typescript-sdk/get-tier-by-id.mdx +++ b/_snippets/typescript-sdk/get-tier-by-id.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.getTierById({ tierId: 'tier_123', }); diff --git a/_snippets/typescript-sdk/get-tiers.mdx b/_snippets/typescript-sdk/get-tiers.mdx index c477dd9..81d7331 100644 --- a/_snippets/typescript-sdk/get-tiers.mdx +++ b/_snippets/typescript-sdk/get-tiers.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.getTiers({ first: 25, }); diff --git a/_snippets/typescript-sdk/mark-thread-as-done.mdx b/_snippets/typescript-sdk/mark-thread-as-done.mdx index b49caea..de63629 100644 --- a/_snippets/typescript-sdk/mark-thread-as-done.mdx +++ b/_snippets/typescript-sdk/mark-thread-as-done.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.markThreadAsDone({ threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ', diff --git a/_snippets/typescript-sdk/mark-thread-as-todo.mdx b/_snippets/typescript-sdk/mark-thread-as-todo.mdx index be8488f..4a4d4df 100644 --- a/_snippets/typescript-sdk/mark-thread-as-todo.mdx +++ b/_snippets/typescript-sdk/mark-thread-as-todo.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.markThreadAsTodo({ threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ', diff --git a/_snippets/typescript-sdk/page-info-after.mdx b/_snippets/typescript-sdk/page-info-after.mdx index 582458d..943a687 100644 --- a/_snippets/typescript-sdk/page-info-after.mdx +++ b/_snippets/typescript-sdk/page-info-after.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const firstPage = client.getCustomers({}); diff --git a/_snippets/typescript-sdk/remove-customer-from-groups.mdx b/_snippets/typescript-sdk/remove-customer-from-groups.mdx index 3b1bbb4..000cfd0 100644 --- a/_snippets/typescript-sdk/remove-customer-from-groups.mdx +++ b/_snippets/typescript-sdk/remove-customer-from-groups.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'plainApiKey_rO6tIKWU2w0gD_ek9HwjsHMiq1MHsgAn7mhVrcC7MGw', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.removeCustomerFromCustomerGroups({ customerId: 'c_01H1P4TE62AS5KZ4CZFC0578ED', diff --git a/_snippets/typescript-sdk/remove-customer-from-tenants.mdx b/_snippets/typescript-sdk/remove-customer-from-tenants.mdx index 95ba6e9..2725994 100644 --- a/_snippets/typescript-sdk/remove-customer-from-tenants.mdx +++ b/_snippets/typescript-sdk/remove-customer-from-tenants.mdx @@ -1,4 +1,4 @@ -```tsx +```ts const res = await client.removeCustomerFromTenants({ customerIdentifier: { // You can use the customer email diff --git a/_snippets/typescript-sdk/remove-labels.mdx b/_snippets/typescript-sdk/remove-labels.mdx index 2e9b4bb..bd08c01 100644 --- a/_snippets/typescript-sdk/remove-labels.mdx +++ b/_snippets/typescript-sdk/remove-labels.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/remove-members-from-tier.mdx b/_snippets/typescript-sdk/remove-members-from-tier.mdx index 1272f74..93c5e6b 100644 --- a/_snippets/typescript-sdk/remove-members-from-tier.mdx +++ b/_snippets/typescript-sdk/remove-members-from-tier.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.removeMembersFromTier({ memberIdentifiers: [ { diff --git a/_snippets/typescript-sdk/reply-email.mdx b/_snippets/typescript-sdk/reply-email.mdx index ac92d8b..5370476 100644 --- a/_snippets/typescript-sdk/reply-email.mdx +++ b/_snippets/typescript-sdk/reply-email.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/reply-to-response.mdx b/_snippets/typescript-sdk/reply-to-response.mdx index 89f6e32..0535559 100644 --- a/_snippets/typescript-sdk/reply-to-response.mdx +++ b/_snippets/typescript-sdk/reply-to-response.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/reply-to-thread.mdx b/_snippets/typescript-sdk/reply-to-thread.mdx index 6b13587..c34c356 100644 --- a/_snippets/typescript-sdk/reply-to-thread.mdx +++ b/_snippets/typescript-sdk/reply-to-thread.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/send-email.mdx b/_snippets/typescript-sdk/send-email.mdx index 9ba3b0d..3ef40fa 100644 --- a/_snippets/typescript-sdk/send-email.mdx +++ b/_snippets/typescript-sdk/send-email.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); diff --git a/_snippets/typescript-sdk/set-customer-tenants.mdx b/_snippets/typescript-sdk/set-customer-tenants.mdx index 750d85a..91a54b6 100644 --- a/_snippets/typescript-sdk/set-customer-tenants.mdx +++ b/_snippets/typescript-sdk/set-customer-tenants.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.setCustomerTenants({ customerIdentifier: { // You can use the customer email diff --git a/_snippets/typescript-sdk/snooze-thread.mdx b/_snippets/typescript-sdk/snooze-thread.mdx index 562c41d..e3f81cf 100644 --- a/_snippets/typescript-sdk/snooze-thread.mdx +++ b/_snippets/typescript-sdk/snooze-thread.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.snoozeThread({ threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ', diff --git a/_snippets/typescript-sdk/ui-badge.mdx b/_snippets/typescript-sdk/ui-badge.mdx index 7a99f34..8397055 100644 --- a/_snippets/typescript-sdk/ui-badge.mdx +++ b/_snippets/typescript-sdk/ui-badge.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; uiComponent.badge({ label: 'Subscribed', color: 'GREEN' }); diff --git a/_snippets/typescript-sdk/ui-container.mdx b/_snippets/typescript-sdk/ui-container.mdx index d11ca4f..0b807c5 100644 --- a/_snippets/typescript-sdk/ui-container.mdx +++ b/_snippets/typescript-sdk/ui-container.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; uiComponent.container({ diff --git a/_snippets/typescript-sdk/ui-copy-button.mdx b/_snippets/typescript-sdk/ui-copy-button.mdx index 60b36cb..434766e 100644 --- a/_snippets/typescript-sdk/ui-copy-button.mdx +++ b/_snippets/typescript-sdk/ui-copy-button.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; uiComponent.copyButton({ diff --git a/_snippets/typescript-sdk/ui-divider.mdx b/_snippets/typescript-sdk/ui-divider.mdx index f79ac81..9893d65 100644 --- a/_snippets/typescript-sdk/ui-divider.mdx +++ b/_snippets/typescript-sdk/ui-divider.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; [ diff --git a/_snippets/typescript-sdk/ui-link-button.mdx b/_snippets/typescript-sdk/ui-link-button.mdx index 3a068bf..78991fc 100644 --- a/_snippets/typescript-sdk/ui-link-button.mdx +++ b/_snippets/typescript-sdk/ui-link-button.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; uiComponent.linkButton({ diff --git a/_snippets/typescript-sdk/ui-plain-text.mdx b/_snippets/typescript-sdk/ui-plain-text.mdx index 6e87106..38596bc 100644 --- a/_snippets/typescript-sdk/ui-plain-text.mdx +++ b/_snippets/typescript-sdk/ui-plain-text.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; [ diff --git a/_snippets/typescript-sdk/ui-row.mdx b/_snippets/typescript-sdk/ui-row.mdx index d8b64f2..fa456a9 100644 --- a/_snippets/typescript-sdk/ui-row.mdx +++ b/_snippets/typescript-sdk/ui-row.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; uiComponent.row({ diff --git a/_snippets/typescript-sdk/ui-spacer.mdx b/_snippets/typescript-sdk/ui-spacer.mdx index 59ba5dd..3e0f553 100644 --- a/_snippets/typescript-sdk/ui-spacer.mdx +++ b/_snippets/typescript-sdk/ui-spacer.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; [ diff --git a/_snippets/typescript-sdk/ui-text.mdx b/_snippets/typescript-sdk/ui-text.mdx index 94fe86a..dc0fe62 100644 --- a/_snippets/typescript-sdk/ui-text.mdx +++ b/_snippets/typescript-sdk/ui-text.mdx @@ -1,4 +1,4 @@ -```tsx +```ts import { uiComponent } from '@team-plain/typescript-sdk'; [ diff --git a/_snippets/typescript-sdk/unassign-thread.mdx b/_snippets/typescript-sdk/unassign-thread.mdx index 28f0152..6e4da26 100644 --- a/_snippets/typescript-sdk/unassign-thread.mdx +++ b/_snippets/typescript-sdk/unassign-thread.mdx @@ -1,9 +1,7 @@ -```tsx +```ts import { PlainClient } from '@team-plain/typescript-sdk'; -const client = new PlainClient({ - apiKey: 'XXX', -}); +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); const res = await client.unassignThread({ threadId: 'th_01H8H46YPB2S4MAJM382FG9423', diff --git a/_snippets/typescript-sdk/update-customer-company.mdx b/_snippets/typescript-sdk/update-customer-company.mdx index e2eddc2..1209e11 100644 --- a/_snippets/typescript-sdk/update-customer-company.mdx +++ b/_snippets/typescript-sdk/update-customer-company.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.updateCustomerCompany({ customerId: 'c_01H14DFQ4PDYBH398J1E99TWSS', companyIdentifier: { diff --git a/_snippets/typescript-sdk/upsert-tenant.mdx b/_snippets/typescript-sdk/upsert-tenant.mdx index 226f505..c4273c8 100644 --- a/_snippets/typescript-sdk/upsert-tenant.mdx +++ b/_snippets/typescript-sdk/upsert-tenant.mdx @@ -1,4 +1,8 @@ -```tsx +```ts +import { PlainClient } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + const res = await client.upsertTenant({ identifier: { externalId: 'team_123', diff --git a/_snippets/typescript-sdk/upsert-thread-field.mdx b/_snippets/typescript-sdk/upsert-thread-field.mdx new file mode 100644 index 0000000..fb58646 --- /dev/null +++ b/_snippets/typescript-sdk/upsert-thread-field.mdx @@ -0,0 +1,20 @@ +```ts +import { PlainClient, ThreadFieldSchemaType } from '@team-plain/typescript-sdk'; + +const client = new PlainClient({ apiKey: 'plainApiKey_xxx' }); + +const res = await client.upsertThreadField({ + identifier: { + key: 'product_area', + threadId: 'th_01HVNWFJS395XVPPBJNE6A8BHP', + }, + type: ThreadFieldSchemaType.String, + stringValue: 'security', +}); + +if (res.error) { + console.error(res.error); +} else { + console.log(res.data); +} +``` diff --git a/api-reference/graphql/threads/thread-fields.mdx b/api-reference/graphql/threads/thread-fields.mdx new file mode 100644 index 0000000..c892076 --- /dev/null +++ b/api-reference/graphql/threads/thread-fields.mdx @@ -0,0 +1,33 @@ +--- +title: 'Thread fields' +--- + +Thread fields allow you to extend Plain's thread data model. The thread fields which you want to support have to conform to a schema configured in **Settings** → **Thread fields**. + +Thread fields can be nested and be either a boolean, text or a string enum. + +Thread fields can be required. When they are required, their value must be set in order for the thread to be marked as done. + +For interacting with thread fields via the API, every field has a `key` defined in its schema. Keys make it possible to quickly refer to a thread field without having to know its ID in the schema. For example if you have a field called "Product Area" the key you might choose for the key to be `product_area`. + +### Upsert a field + + + + + + + + + + +### Delete a field + + + + + + + + + diff --git a/data-model.mdx b/data-model.mdx index 2b14993..9bf2d62 100644 --- a/data-model.mdx +++ b/data-model.mdx @@ -31,6 +31,8 @@ Threads are created automatically by inbound communications or programmatically Each thread has a timeline. The timeline contains all relevant communication, events and other updates such as assignment changes. +Threads can be extended with custom attributes called thread fields. + ## Labels Labels are a lightweight way of categorizing threads by topic (e.g., bugs, feature requests, demo request, etc.). A thread can have one or more labels, and each label has a name and an icon that you choose in your settings. diff --git a/mint.json b/mint.json index fa7d421..d73c46c 100644 --- a/mint.json +++ b/mint.json @@ -85,7 +85,14 @@ }, { "group": "Adding context", - "pages": ["company-support", "tenant-support", "customer-cards", "customer-groups", "events"] + "pages": [ + "company-support", + "tenant-support", + "customer-cards", + "thread-fields", + "customer-groups", + "events" + ] }, { "group": "Using Plain", @@ -139,6 +146,17 @@ "api-reference/graphql/tenants/set-customer-tenants" ] }, + { + "group": "Threads", + "pages": [ + "api-reference/graphql/threads", + "api-reference/graphql/threads/create", + "api-reference/graphql/threads/assignment", + "api-reference/graphql/threads/thread-fields", + "api-reference/graphql/threads/status-changes", + "api-reference/graphql/threads/autoresponders" + ] + }, { "group": "Tiers", "pages": [ @@ -173,16 +191,6 @@ "api-reference/graphql/messaging/reply-email" ] }, - { - "group": "Threads", - "pages": [ - "api-reference/graphql/threads", - "api-reference/graphql/threads/create", - "api-reference/graphql/threads/assignment", - "api-reference/graphql/threads/status-changes", - "api-reference/graphql/threads/autoresponders" - ] - }, "api-reference/graphql/pagination", "api-reference/graphql/error-handling", "api-reference/graphql/error-codes", diff --git a/thread-fields.mdx b/thread-fields.mdx new file mode 100644 index 0000000..54b1a56 --- /dev/null +++ b/thread-fields.mdx @@ -0,0 +1,20 @@ +--- +title: Thread fields +description: Extend and customise Plain's data model. +--- + +To be able to keep track of additional information related to a support request, you can configure additional custom fields you want to store on a thread. + +To configure the schema for thread fields go to **Settings** → **Thread fields** + +Thread fields can either be: + +- A boolean (true or false) +- Text +- A dropdown (single select from a predetermined list) + +Thread fields can also be nested and be conditional on answers from other fields. + +Fields can also be marked as required. This is useful when there is some information you want to collect on every support request before it is marked as done. + +Thread fields can also be **auto-filled via AI**. To enable this behaviour in the settings for any thread field enable "Autofill via AI". The description you provide for each field will be used to guide suggestions.