Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/selfish-oranges-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@team-plain/typescript-sdk': minor
---

Added support for sending chats as a customer `sendCustomerChat`
15 changes: 15 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
AssignThreadDocument,
type AttachmentUploadUrlPartsFragment,
ChangeThreadPriorityDocument,
type ChatPartsFragment,
CompaniesDocument,
type CompanyPartsFragment,
type CompanyTierMembershipPartsFragment,
Expand Down Expand Up @@ -61,6 +62,7 @@ import {
ReplyToThreadDocument,
SearchCompaniesDocument,
SearchTenantsDocument,
SendCustomerChatDocument,
SendNewEmailDocument,
SetCustomerTenantsDocument,
SnoozeThreadDocument,
Expand Down Expand Up @@ -1186,4 +1188,17 @@ export class PlainClient {

return unwrapData(res, (q) => nonNullable(q.createIndexedDocument.indexedDocument));
}

async sendCustomerChat(
input: VariablesOf<typeof SendCustomerChatDocument>['input']
): SDKResult<ChatPartsFragment> {
const res = await request(this.#ctx, {
query: SendCustomerChatDocument,
variables: {
input,
},
});

return unwrapData(res, (q) => nonNullable(q.sendCustomerChat.chat));
}
}
14 changes: 14 additions & 0 deletions src/graphql/fragments/chatParts.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fragment ChatParts on Chat {
id
text
attachments {
id
}
createdAt {
...DateTimeParts
}
updatedAt {
...DateTimeParts
}

}
10 changes: 10 additions & 0 deletions src/graphql/mutations/sendCustomerChat.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mutation sendCustomerChat($input:SendCustomerChatInput!) {
sendCustomerChat(input:$input){
chat {
...ChatParts
}
error {
...MutationErrorParts
}
}
}
Loading
Loading