Chat with the Operator
4 minute read
What you’ll learn
In this how to guide you’ll learn:
- What is the in-app chat feature
- Chat relationships & workflow
- The queries and mutations you can use to work with in-app chat
What is in-app chat?
In-app chat is a text-based communication tool on the Marketplacer platform, facilitating near real-time, company-to-company conversations between Operators and Sellers. This streamlined communication enhances issue resolution for partners within the Marketplacer ecosystem.
If you’re an Operator looking leverage the Operator API to chat with Sellers, check out this article.
In-app chat is available in both the Operator or Seller portals, but can also be accessed via the Operator and Seller APIs. This guide focuses on how you can use the Seller API to chat with the Operator.
Chat content
It is a key term of your use of this Service that you must not input any personal, sensitive, or financial data into the Service (In-app Chat).Chat Relationships & Workflow
Chat Relationships
A simplified view of the relationships between an Operator and Sellers using In-app Chat on a Marketplacer instance is shown below:
The takeaways from this are:
- An Operator can have multiple chat’s with different Sellers
- A Seller only has 1 chat with the Operator
- Sellers cannot chat with each other
- Chat messages are a single continuous thread between the Operator and Seller
- Irrespective of whether separate Operator API keys are used to generate chat messages on the same Marketplacer instance - those chat messages all appear in the same thread
- Irrespective of whether separate Seller API keys are used to generate chat messages under the same Seller Account - those chat messages all appear in the same thread
- Seller API keys use to generate chat messages under separate Seller Accounts will result in a separate chat thread for each
Chat Workflows
There are 3 basic workflows when using In-app chat:
- Send new message workflow
- Reply to a message workflow
- Read message workflow
Send New Message Workflow
chatMessageCreate
sends a message to the Operator
Reply to Message Workflow
chatMessages
fetch chat messageschatMessageRead
sets thereadAt
field on chat messages sent by the OperatorchatMessageCreate
sends a reply message to the Operator
Read Message Workflow
chatMessages
fetch chat messageschatMessageRead
sets thereadAt
field on chat messages sent by the Operator
Examples of these queries and mutations can be found below, as well as in our API Collections.
Query & Mutation Examples
GraphQL Best Practices
The examples provided below adhere to our GraphQL Best Practices Guide, with the exception of utilizing variables - this is primarily for reasons of readability, but it also makes the code easier to copy and paste into your favorite tool so you can use straightaway.
In production code it’s highly recommended that you adopt variables, as demonstrated by the examples in our API collections.
chatMessageSend
Create a chat message between operator and seller.
mutation SendMessgaeToOperator {
chatMessageCreate(
input: {
message: "Can you check to see when my remittance will be paid?"
}
) {
chatMessage {
id
}
errors {
field
messages
}
}
}
In this mutation we:
- Provide a message we want to send to the Operator
- Request the ID of the resulting Chat Message
- Request any errors associated with the mutation call
chatMessages
Fetches chat messages between Operator and a Seller
query GetChatMessages {
chatMessages(first: 10, after: null) {
totalCount
pageInfo {
hasNextPage
endCursor
}
nodes {
id
createdAt
message
readAt
sentByType
}
}
}
In this example we fetch:
- The first 10 Chat Messages (we are not passing an
after
cursor) - We also use pagination to determine if:
- There is another page of data (
hasNextPage
) - If so, obtain the cursor we need to supply to our subsequent call (
endCursor
)
- There is another page of data (
chatMessageRead
Mark a chat message as read
mutation ConfirmReadOfChatMessage {
chatMessageRead(input: { sentBy: "Admin" }) {
errors {
messages
field
}
}
}
In this mutation we:
- Supply the user class (
sentBy
) - Request any errors associated with the mutation call