Chat with Sellers
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 a Seller looking leverage the Seller API to chat with Operators, 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 Operator API to chat with your sellers.
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
sellersForChats
fetch Sellers sorted by their latest chat message created date, (this included Sellers that do not have any chat messages).chatMessageCreate
sends a message to the specified seller (using the Seller Id)
Reply to Message Workflow
chatMessages
fetch chat messages for a specific SellerchatMessageRead
sets thereadAt
field on chat messages sent by a specific sellerchatMessageCreate
sends a reply message to the specified seller (using the Seller Id)
Read Message Workflow
chatMessages
fetch chat messages for a specific SellerchatMessageRead
sets thereadAt
field on chat messages sent by a specific seller
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.
sellersForChats
Fetch sellers sorted by their latest chat messages’ created timestamp
query FetchSellersForChat {
sellersForChats(first: 10, after: null, q: "Cell Phone") {
totalCount
pageInfo {
hasNextPage
endCursor
}
nodes {
id
businessName
}
}
}
In this example we fetch:
- The first 10 Sellers (we are not passing an
after
cursor), that haveCell Phones
somewhere in their business name - 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 (
chatMessageSend
Create a chat message between operator and seller.
mutation SendMessgaeToSeller {
chatMessageCreate(
input: {
message: "Can you check to see when order 12345 will be dispatched?"
sellerId: "U2VsbGVyLTY2MDExOQ=="
}
) {
chatMessage {
id
}
errors {
field
messages
}
}
}
In this mutation we:
- Provide a message we want to send to the Seller
- Identify the Seller we want to target by their ID
- 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, sellerId: "U2VsbGVyLTY2MDExOQ==") {
totalCount
pageInfo {
hasNextPage
endCursor
}
nodes {
id
createdAt
message
readAt
seller {
businessName
}
sentByType
}
}
}
In this example we fetch:
- The first 10 Chat Messages (we are not passing an
after
cursor) for a Seller based on their ID - 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: { seller: "U2VsbGVyLTY2MDExOQ==", sentBy: "User" }) {
errors {
messages
field
}
}
}
In this mutation we:
- Identify the Seller who’s chats we want to mark as being read
- Supply the user class (
sentBy
) - Request any errors associated with the mutation call