Mutations
The root Mutation type in a GraphQL schema defines all the write operations that can change data. It is analogous to performing HTTP verbs such as POST, PATCH, and DELETE.
Mutations can take arguments as input similar to the body of a POST request in REST. Like GraphQL queries, mutations can also return fields. This can be useful for fetching the new state of an object after an update.
Mutations are structured like this:
mutation {
theNameOfTheMutation {
JSON objects to return
}
}
approveSubmission
Approves a pending expert submission.
Mutation Details
approveSubmission(id: ID!): Submission!
Example
Mutation
mutation {
approveSubmission(id: "e394e75b-e159-4d7c-a02c-9445da754994") {
id
status
reviewedAt
}
}
Response
"data": {
"approveSubmission": {
"id": "e394e75b-e159-4d7c-a02c-9445da754994",
"status": "approved",
"reviewedAt": 1550534056605
}
},
rejectSubmission
Rejects a pending expert submission.
Mutation Details
rejectSubmission(id: ID!): Submission!
Example
Mutation
mutation {
rejectSubmission(id: "e394e75b-e159-4d7c-a02c-9445da754994") {
id
status
reviewedAt
}
}
Response
"data": {
"rejectSubmission": {
"id": "e394e75b-e159-4d7c-a02c-9445da754994",
"status": "rejected",
"reviewedAt": 1550534056605
}
},
createPersona
Creates a persona on the GUURU platform that can be used to accept chats. This persona information will be shown to the end user as the author of the messages sent to the accepted chat.
Should be used when handling chats with agents on a third party tool.
The
providerId
is the unique id of the agent in your system of record. If multiple calls tocreatePersona
are issued with the sameproviderId
only one persona will be created. The subsequent requests will return the same id. You can also call this mutation to update the name, email or photo of an existing persona by passing the new information and the currentproviderId
.
Mutation Details
input PersonaInput {
"The ID of this persona in the system of record"
providerId: ID!
name: String!
email: String
photoUrl: String
}
createPersona(input: PersonaInput!): ID!
Example
A full working example of a call to createPersona
is available in
Examples.
Mutation
mutation {
createPersona(input: {
providerId: "any-unique-agent-id-from-your-system",
name: "John Doe",
email: "johndoe@example.com",
photoUrl: "https://cdn.guuru.com/assets/logo/robotAvatar.png"
})
}
Response
"data": {
"createPersona": "ab22a12e-cefd-4f67-945b-c215c42202b4"
}
acceptChat
Accepts a pending chat assigned to an expert.
When handling chats with agents on a third party tool, use the personaId
field. See Create Persona on
how to create a persona.
An error will be returned if the chat was already accepted. You should expect and handle this error gracefully.
Mutation Details
input AcceptChatInput {
personaId: ID!
}
acceptChat(id: ID!, input: AcceptChatInput): Chat!
Example
Mutation
mutation {
acceptChat(id: "O2bqy2CsAaS7RBXZrhMOB", input: {
personaId: "ab22a12e-cefd-4f67-945b-c215c42202b4"
}) {
id
status
messages {
edges {
node {
id
type
createdAt
... on TextMessage {
text
}
... on AttachmentMessage {
attachment {
id
filename
mimetype
url
}
}
author {
__typename
... on BotAuthor {
id
}
... on UserAuthor {
id
}
... on ExpertAuthor {
id
name
}
}
}
}
}
}
}
Response
"data": {
"acceptChat": {
"id": "O2bqy2CsAaS7RBXZrhMOB",
"status": "open",
"messages": [{
"node": {
"id": "d2d335fd-2377-4534-ba1a-9a01fdf94e9c",
"type": "text",
"createdAt": 1550534056605,
"text": "Hello",
"author": {
"__typename": "UserAuthor",
"id": "owRNDrixHcNnPMVQUKpv2Lj5TQ82",
},
}
}],
}
},
closeChat
Close a chat that belongs to the expert.
Mutation Details
closeChat(id: ID!): Chat!
Example
Mutation
mutation {
closeChat(id: "O2bqy2CsAaS7RBXZrhMOB") {
id
status
}
}
Response
"data": {
"closeChat": {
"id": "O2bqy2CsAaS7RBXZrhMOB",
"status": "closed",
}
},
openChat
Open a closed chat that belongs to the expert.
Mutation Details
openChat(id: ID!): Chat!
Example
Mutation
mutation {
openChat(id: "O2bqy2CsAaS7RBXZrhMOB") {
id
status
}
}
Response
"data": {
"openChat": {
"id": "O2bqy2CsAaS7RBXZrhMOB",
"status": "open",
}
},
sendChatMessage
Send a message to an open chat.
Mutation Details
sendChatMessage(input: ChatMessageInput!): Boolean!
Example
Mutation
mutation {
sendChatMessage(input: {
chatId: "O2bqy2CsAaS7RBXZrhMOB",
posting: {
type: "text",
text: "How can I help you ?",
}
})
}
mutation {
sendChatMessage(input: {
chatId: "O2bqy2CsAaS7RBXZrhMOB",
posting: {
type: "attachment",
mimetype: "image/png",
address: "https://scontentd.guuru.com/partner/guuru-qa/attachments/OwWMbHm_2y7NJNGUTpEyb/499663b1-5528-472b-a98c-3ca540eb3186/shuttle.png",
filename: "rocket.png",
}
})
}
Response
"data": {
"sendChatMessage": true
},
transferToPersona
Transfer an open chat directly to another persona.
Mutation Details
transferToPersona(chatId: ID!, personaId: ID!): Boolean!
Example
Mutation
mutation {
transferToPersona(
chatId: "O2bqy2CsAaS7RBXZrhMOB",
personaId: "e393edb0-ad3d-432e-960d-35593485bfa6"
)
}
Response
"data": {
"transferToPersona": true
},