Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/p-7155-write-docs-for-sla-webhoo…
Browse files Browse the repository at this point in the history
…k' into p-7155-write-docs-for-sla-webhook
  • Loading branch information
jesushernandez committed May 1, 2024
2 parents aa7e0d4 + 3b01d3b commit 6cffd12
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 10 deletions.
2 changes: 1 addition & 1 deletion _snippets/graphql/add-members-to-tier.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mutation addMembersToTier($input: AddMembersToTierInput!) {
"companyId": "co_123"
}
],
"tierId": "tier_123"
"tierIdentifier": { "externalId": "XXX" }
}
}
```
3 changes: 1 addition & 2 deletions _snippets/graphql/remove-members-from-tier.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ mutation removeMembersFromTier($input: RemoveMembersFromTierInput!) {
{
"companyId": "co_123"
}
],
"tierId": "tier_123"
]
}
}
```
2 changes: 1 addition & 1 deletion _snippets/typescript-sdk/add-members-to-tier.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const res = await client.addMembersToTier({
companyId: 'co_123',
},
],
tierId: 'tier_123',
tierIdentifier: { externalId: 'XXX' },
});

if (res.error) {
Expand Down
1 change: 0 additions & 1 deletion _snippets/typescript-sdk/remove-members-from-tier.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const res = await client.removeMembersFromTier({
companyId: 'co_123',
},
],
tierId: 'tier_123',
});

if (res.error) {
Expand Down
13 changes: 11 additions & 2 deletions api-reference/graphql/threads/thread-fields.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ Thread fields can be required. When they are required, their value must be set i

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
### Upsert a thread field

To upsert a thread field you need an API key with the following permissions:

- `threadField:create`
- `threadField:update`

<Tabs>
<Tab title="Typescript SDK">
Expand All @@ -21,7 +26,11 @@ For interacting with thread fields via the API, every field has a `key` defined
</Tab>
</Tabs>

### Delete a field
### Delete a thread field

To delete a thread field you need an API key with the following permissions:

- `threadField:delete`

<Tabs>
<Tab title="Typescript SDK">
Expand Down
2 changes: 2 additions & 0 deletions api-reference/graphql/tiers/add-members.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebarTitle: 'Add companies & tenants'

You can add multiple tenants and companies to a tier in a single mutation.

Companies and tenants can only be in a single tier.

For this mutation you need the following permissions:

- `tierMembership:read`
Expand Down
2 changes: 1 addition & 1 deletion api-reference/graphql/tiers/remove-members.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'Remove companies and tenants to tiers'
sidebarTitle: 'Remove companies & tenants'
---

You can remove companies and tenants from a tier manually in the UI or via the API.
You can remove companies and tenants from the tiers they are part of manually in the UI or via the API.

For this mutation you need the following permissions:

Expand Down
4 changes: 2 additions & 2 deletions api-reference/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ being processed.

Webhook requests are sent as an `HTTP POST` request to the webhook target URL.

### Headers [#headers]
### Headers

- `Accept`: `application/json`
- `Content-Type`: `application/json`
Expand Down Expand Up @@ -119,7 +119,7 @@ The JSON schema for Plain the webhook request body can be found [here](https://c
| `workspaceId` | `string` | The ID of the workspace where the Plain event originated |
| `payload` | `object` | The Plain event's payload [(Example)](/api-reference/webhooks/thread-created); |

### Webhook Metadata [#webhook-metadata]
### Webhook Metadata

All the following fields are also sent as [HTTP headers](#headers).

Expand Down
36 changes: 36 additions & 0 deletions api-reference/webhooks/typescript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: 'Webhooks and Typescript'
sidebarTitle: 'Using Typescript'
---

When using webhooks with Typescript, you can use a utility called `parsePlainWebhook` in the Typescript SDK to parse the webhook requests.

This makes sure your code is 100% type safe and that all requests are correctly validated.

```ts
import Express from 'express';
import { parsePlainWebhook } from '@team-plain/typescript-sdk';

const app = Express();

app.post('/handler/', function (req: Express.Request, res: Express.Response) {
const parseResult = parsePlainWebhook(req.body);

// If this errors it means the request is not valid
// you can safely ignore it!
if (parseResult.error) {
res.status(400);
return;
}

// This is now fully typed and safe to use.
const webhookBody = parseResult.data;

// You can use the eventType to filter down to a specific event type
if (webhookBody.payload.eventType === 'thread.thread_created') {
console.log(webhookBody.payload.thread.id);
}

res.status(200);
});
```
1 change: 1 addition & 0 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
"group": "Webhooks",
"pages": [
"api-reference/webhooks",
"api-reference/webhooks/typescript",
"api-reference/webhooks/thread-created",
"api-reference/webhooks/thread-status-transitioned",
"api-reference/webhooks/thread-assignment-transitioned",
Expand Down
6 changes: 6 additions & 0 deletions tiers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ When configuring an SLA you can set when you want to be warned of a breach. For
SLAs can also be driven by priority of threads. This allows you to have a different SLAs for "Urgent" vs "Normal" priority threads. If you have configure multiple SLAs for the same priority then only the first SLA will apply.

If you want to create a 'default' SLA then you can need to first create a tier and make that the default in your settings. Then you can configure SLAs like you would on any other tier.

### Business hours

By default SLAs apply at all times. They can be configured to only count working hours by toggling on **Only during business hours**.

To configure business hours go to **Settings****Business hours**

0 comments on commit 6cffd12

Please sign in to comment.