Skip to content

Commit aa9d212

Browse files
committed
Add sendChat
1 parent cc84f17 commit aa9d212

File tree

6 files changed

+740
-52
lines changed

6 files changed

+740
-52
lines changed

.changeset/many-news-divide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@team-plain/typescript-sdk': minor
3+
---
4+
5+
Added sendChat method which lets you send chat messages as a machine user

src/client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {
6464
ReplyToThreadDocument,
6565
SearchCompaniesDocument,
6666
SearchTenantsDocument,
67+
SendChatDocument,
6768
SendCustomerChatDocument,
6869
SendNewEmailDocument,
6970
SetCustomerTenantsDocument,
@@ -1219,6 +1220,19 @@ export class PlainClient {
12191220
return unwrapData(res, (q) => nonNullable(q.sendCustomerChat.chat));
12201221
}
12211222

1223+
async sendChat(
1224+
input: VariablesOf<typeof SendChatDocument>['input']
1225+
): SDKResult<ChatPartsFragment> {
1226+
const res = await request(this.#ctx, {
1227+
query: SendChatDocument,
1228+
variables: {
1229+
input,
1230+
},
1231+
});
1232+
1233+
return unwrapData(res, (q) => nonNullable(q.sendChat.chat));
1234+
}
1235+
12221236
async createKnowledgeSource(
12231237
input: VariablesOf<typeof CreateKnowledgeSourceDocument>['input']
12241238
): SDKResult<KnowledgeSourcePartsFragment> {

src/graphql/mutations/sendChat.gql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mutation sendChat($input:SendChatInput!) {
2+
sendChat(input:$input){
3+
chat {
4+
...ChatParts
5+
}
6+
error {
7+
...MutationErrorParts
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)