Hi, i was creating a guest (third party) chat as per instructions found here: https://developer.mypurecloud.com/api/webchat/guestchat.html
and i succesfully (via Postman) created a guest chat, routed it to an agent, and send messages (from the customer side).
What i'm curious about, is how i could send messages to this chat from the agent side, using the API?
I've tried changing the memberID parameter in
POST /api/v2/webchat/guest/conversations/:conversationId/members/:memberId/messages
to be my agent user's ID, or even my agent's participant ID gotten from
GET /api/v2/webchat/guest/conversations/:conversationId/members
But no matter what, i get
{
"message": "You are not authorized to perform the requested action.",
"code": "not.authorized",
"status": 403
}
Is there any way of actually sending the agents' messages from the API? Or is it only possible from the Genesys Cloud Chat UI?
Hi, thanks for the recommendation.
I did try it out just now (POST /api/v2/conversations/chats/:conversationId/communications/:communicationId/messages)
and could still send the messages only from the customer's communicationID. When i tried it with the agent's, i got "403 Forbidden: User is not an active member on the conversation"
Any suggestions?
As it is mentioned on the Agent Chat API page, you need to authenticate as a Contact Center Agent/Genesys Cloud user to obtain an authorization token (using an OAuth Implicit Grant flow, Authorization Code flow or SAML flow - user based authentication).
Then you can send messages if your Contact Center Agent (the account you used to authenticate and get authorization token) is an active participant of the chat. If the account you have used to authenticate is not an active participant in the chat, it is not possible to send messages into that chat session.
In the POST /api/v2/conversations/chats/{conversationId}/communications/{communicationId}/messages:
conversationId is of course the id of the conversation corresponding to that chat
communicationId refers to the id you can find in the chats array under the agent's participant (conversation info).
I mean if you have subscribed to conversations notifications (v2.users.{id}.conversations) or if you do a Get on the conversation using this or any other way to get conversation info/context.
Then, for the participant structure that corresponds to the agent --> chats[0].id
Ah, thank you. It makes sense, i was using Oauth2.0 Client credentials.
Just tried the Code Authorization Grant tutorial, and can't seem to run the Python example succesfully (aside from it being python 2), i'll let you know if i can get it to work.
Regards,