Skip to content

Commit

Permalink
Port all changes from current docs to new docs + various clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvagni committed Nov 20, 2023
1 parent 31ff975 commit 5aa4ee5
Show file tree
Hide file tree
Showing 49 changed files with 545 additions and 244 deletions.
21 changes: 21 additions & 0 deletions _snippets/graphql/reply-to-thread.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```graphql Mutation
mutation replyToThread($input: ReplyToThreadInput!) {
replyToThread(input: $input) {
error {
message
type
code
}
}
}
```

```json Variables
{
"input": {
"threadId": "th_01H8H46YPB2S4MAJM382FG9423",
"textContent": "The plain text version of your reply goes here.",
"markdownContent": "The markdown **version** of your _reply_ goes here."
}
}
```
21 changes: 2 additions & 19 deletions _snippets/typescript-sdk/create-customer-event-response.mdx
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
```json
{
"__typename": "CustomerEvent",
"id": "ce_01HB924RWAW8H3Q8KZDFWYBJHZ",
"id": "tev_01HB924RWAW8H3Q8KZDFWYBJHZ",
"externalId": null,
"customer": {
"id": "c_01H14DFQ4PDYBH398J1E99TWSS"
},
"customerId": "c_01H14DFQ4PDYBH398J1E99TWSS",
"title": "API key generated",
"components": [
{
"__typename": "ComponentText",
"text": "New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles."
}
{
"__typename": "ComponentSpacer",
"spacerSize": "M"
}
{
"__typename": "ComponentLinkButton",
"linkButtonLabel": "View in admin",
"linkButtonUrl": "https://admin.your-app.com"
}
],
"createdAt": {
"__typename": "DateTime",
"iso8601": "2023-09-26T15:36:23.690Z",
Expand Down
6 changes: 1 addition & 5 deletions _snippets/typescript-sdk/create-customer-event.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const res = await client.createCustomerEvent({
// externalId: 'YOUR_ID',

// ...or you can use the customer's id in Plain:
// customerId: 'c_123'
// customerId: 'c_01H14DFQ4PDYBH398J1E99TWSS'
},

components: [
Expand All @@ -38,10 +38,6 @@ const res = await client.createCustomerEvent({
// as an idempotency key while also letting you correlate an event to
// something your systems.
externalId: 'XXX',

// Optional - if provided then the event will only be shown
// in a single thread vs all threads from a customer
threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ',
});

if (res.error) {
Expand Down
27 changes: 27 additions & 0 deletions _snippets/typescript-sdk/create-thread-event-response.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
```json
{
"__typename": "ThreadEvent",
"id": "tev_01HB924RWAW8H3Q8KZDFWYBJHZ",
"externalId": "ex-id-1",
"customerId": "c_01H14DFQ4PDYBH398J1E99TWSS",
"title": "API key generated",
"createdAt": {
"__typename": "DateTime",
"iso8601": "2023-09-26T15:36:23.690Z",
"unixTimestamp": "1695742583690"
},
"createdBy": {
"__typename": "MachineUserActor",
"machineUserId": "mu_01HBZM0TZAKAZPJ47NX7X7XMDY"
},
"updatedAt": {
"__typename": "DateTime",
"iso8601": "2023-10-05T10:10:04.785Z",
"unixTimestamp": "1696500604785"
},
"updatedBy": {
"__typename": "MachineUserActor",
"machineUserId": "mu_01HBZM0TZAKAZPJ47NX7X7XMDY"
}
}
```
39 changes: 39 additions & 0 deletions _snippets/typescript-sdk/create-thread-event.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
```tsx
import { PlainClient, uiComponent } from '@team-plain/typescript-sdk';

const client = new PlainClient({
apiKey: 'XXX',
debug: true,
});

const res = await client.createThreadEvent({
title: 'API key generated',

threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ',

components: [
uiComponent.text({
text: 'New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles.',
}),
uiComponent.spacer({
size: 'M',
}),
uiComponent.linkButton({
label: 'View in admin',
url: 'https://admin.your-app.com',
}),
],

// Optional - if provided, this will ensure that this event can only
// be created once and fail on the second time. This external id acts
// as an idempotency key while also letting you correlate an event to
// something your systems.
externalId: 'ex-id-1',
});

if (res.error) {
console.error(res.error);
} else {
console.log(res.data);
}
```
2 changes: 1 addition & 1 deletion _snippets/typescript-sdk/reply-email.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PlainClient } from '@team-plain/typescript-sdk';

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

client.replyToEmail({
const res = await client.replyToEmail({
customerId: 'c_01GTC6ZHCMAGR06FMPN9VY5J95',
inReplyToEmailId: 'em_01GM2X8K7D3RZ7ZFGHZ2AYG3SA',
textContent: 'The plain text version of your reply goes here.',
Expand Down
17 changes: 17 additions & 0 deletions _snippets/typescript-sdk/reply-to-response.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```tsx
import { PlainClient } from '@team-plain/typescript-sdk';

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

const res = await client.replyToThread({
threadId: 'th_01HD44FHMCDSSWE38N14FSYV6K',
textContent: 'The plain text version of your reply goes here.',
markdownContent: 'The markdown **version** of your reply goes here.',
});

if (res.error) {
console.error(res.error);
} else {
console.log(res.data);
}
```
3 changes: 3 additions & 0 deletions _snippets/typescript-sdk/reply-to-thread-response.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```json
{}
```
2 changes: 1 addition & 1 deletion _snippets/typescript-sdk/send-email.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PlainClient } from '@team-plain/typescript-sdk';

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

client.sendNewEmail({
const res = await client.sendNewEmail({
customerId: 'c_01GTC6ZHCMAGR06FMPN9VY5J95',
threadId: 'th_01HD44FHMCDSSWE38N14FSYV6K',
subject: 'Your account has a problem',
Expand Down
4 changes: 0 additions & 4 deletions _snippets/webhooks/customer-created.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-04T14:17:41.991Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
4 changes: 0 additions & 4 deletions _snippets/webhooks/customer-deleted.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-04T14:17:41.991Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
8 changes: 0 additions & 8 deletions _snippets/webhooks/customer-group-changed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "ACTIVE",
"statusChangedAt": "2023-10-19T14:12:25.267Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [
Expand Down Expand Up @@ -76,10 +72,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "ACTIVE",
"statusChangedAt": "2023-10-19T14:12:25.267Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
8 changes: 0 additions & 8 deletions _snippets/webhooks/customer-updated.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "ACTIVE",
"statusChangedAt": "2023-10-19T14:12:25.267Z",
"markedAsSpamAt": "2023-10-19T14:21:43.616Z",
"markedAsSpamBy": {
"actorType": "user",
Expand Down Expand Up @@ -45,10 +41,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-04T14:17:41.991Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
102 changes: 102 additions & 0 deletions _snippets/webhooks/thread-chat-sent.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
```json
{
"timestamp": "2023-11-02T15:32:28.831Z",
"workspaceId": "w_01GST0W989ZNAW53X6XYHAY87P",
"payload": {
"eventType": "thread.chat_sent",
"chat": {
"timelineEntryId": "t_01HE8AM6GZG6C3CM344HFDM3J3",
"id": "ch_01HE8AM6GZPZ3Q3RBEVE5TZ80X",
"customerReadAt": null,
"attachments": [],
"text": "You are welcome!",
"createdAt": "2023-11-02T15:32:28.831Z",
"createdBy": {
"actorType": "user",
"userId": "u_01H1V4NA10RMHWFBXB6A1ZBYRA"
},
"updatedAt": "2023-11-02T15:32:28.831Z",
"updatedBy": {
"actorType": "user",
"userId": "u_01H1V4NA10RMHWFBXB6A1ZBYRA"
}
},
"thread": {
"id": "th_01HDRC3CRY6ESPZJ7FZCTRQWYH",
"customer": {
"id": "c_01HDRC3CJHBWBAAF4K63Z11XZ5",
"email": {
"email": "[email protected]",
"isVerified": false,
"verifiedAt": null
},
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
"createdAt": "2023-10-27T10:50:24.209Z",
"createdBy": {
"actorType": "system",
"system": "email_inbound_handler"
},
"updatedAt": "2023-11-02T08:57:32.944Z",
"updatedBy": {
"actorType": "user",
"userId": "u_01H1V4NA10RMHWFBXB6A1ZBYRA"
}
},
"title": "Unable to tail logs",
"previewText": "Hey, I am currently unable to tail the logs of the service svc-8af1e3",
"priority": 2,
"externalId": null,
"status": "TODO",
"statusChangedAt": "2023-11-02T08:57:32.943Z",
"statusChangedBy": {
"actorType": "user",
"userId": "u_01H1V4NA10RMHWFBXB6A1ZBYRA"
},
"statusDetail": null,
"assignee": null,
"assignedAt": null,
"labels": [],
"firstInboundMessageInfo": {
"timestamp": "2023-10-27T10:50:24.323Z",
"messageSource": "EMAIL"
},
"firstOutboundMessageInfo": {
"timestamp": "2023-10-27T10:50:52.944Z",
"messageSource": "EMAIL"
},
"lastInboundMessageInfo": {
"timestamp": "2023-10-27T15:05:30.223Z",
"messageSource": "EMAIL"
},
"lastOutboundMessageInfo": {
"timestamp": "2023-10-27T15:04:49.521Z",
"messageSource": "EMAIL"
},
"supportEmailAddresses": ["[email protected]"],
"createdAt": "2023-10-27T10:50:24.323Z",
"createdBy": {
"actorType": "system",
"system": "email_inbound_handler"
},
"updatedAt": "2023-11-02T08:57:32.943Z",
"updatedBy": {
"actorType": "user",
"userId": "u_01H1V4NA10RMHWFBXB6A1ZBYRA"
}
}
},
"id": "pEv_01HE8AM6GZVS1S3609PFGR30FE",
"webhookMetadata": {
"webhookTargetId": "whTarget_01HD4400VTDJQ646V6RY37SR7K",
"webhookDeliveryAttemptId": "whAttempt_01HE8ANGEGVQVTCY3DD30CZ8G4",
"webhookDeliveryAttemptNumber": 1,
"webhookDeliveryAttemptTimestamp": "2023-11-02T15:33:11.760Z"
},
"type": "thread.chat_sent"
}
```
6 changes: 1 addition & 5 deletions _snippets/webhooks/thread-created.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-04T14:17:41.991Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down Expand Up @@ -55,7 +51,7 @@
"firstOutboundMessageInfo": null,
"lastInboundMessageInfo": null,
"lastOutboundMessageInfo": null,
"supportEmailAddresses": [],
"supportEmailAddresses": ["[email protected]"],
"createdAt": "2023-10-19T14:12:25.266Z",
"createdBy": {
"actorType": "system",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-19T14:12:25.142Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
"externalId": null,
"fullName": "Peter Santos",
"shortName": "Peter",
"assignedAt": null,
"assignedToUser": null,
"status": "IDLE",
"statusChangedAt": "2023-10-19T21:24:36.109Z",
"markedAsSpamAt": null,
"markedAsSpamBy": null,
"customerGroupMemberships": [],
Expand Down
Loading

0 comments on commit 5aa4ee5

Please sign in to comment.