webChatApi sendMessage error 403

I am developing an integration application and trying to send a chat message from my app to the active webChat with the guest. I am logged in as an agent, use the developer tools to initiate a chat from a different browser, follow the loginImplicitGrant login (since it's a web app), get the token etc. (although in your documentation you state that this call postWebchatGuestConversationMemberMessages requires no permission). Still, I get 403 when I try to send the message. Am I doing something wrong?

Also please update the documentation to better describe the "body" param of that method. What is the "bodyType"? You have to dig the api to find out.

The authentication required for PureCloud guest chat APIs is described here: https://developer.mypurecloud.com/api/webchat/guestchat.html

If you're trying to send a message as an agent, the APIs are located here: https://developer.mypurecloud.com/api/webchat/agentchat.html

Based on what you're saying it sounds like you're trying to use the guest chat APIs to post a message as an agent and are trying to authenticate as an agent. That won't work.

I am using your WebChat javascript API
https://developer.mypurecloud.com/api/rest/client-libraries/javascript/WebChatApi.html

I can't seem to find that method. On a second check it seems to be in the communicationAPI. Thanks for the info

Indeed, the Agent Chat methods are part of ConversationsApi in the javascript SDK.

https://developer.mypurecloud.com/api/rest/client-libraries/javascript/ConversationsApi.html

1 Like

Thanks for double-checking. Now I need the communicationId. As you describe in this post


the communicationId is per active communication, the id of that. So in my case, the communicationId should be the chatId. It seems that the ChatId and ConversationId are the same. When I try to use your method postConversationsChatCommunicationMessages, I get a 404. Shouldn't it work as expected? Thanks in advance

Hello,

No, the conversationId and the communicationId are different.

If you get active conversations for the logged in user (GET /api/v2/conversations), you will get a list/array of entities (entity = a conversation).
The id at the root of the entity corresponds to the conversationId.
Within that entity (conversation), you have a participants attribute (array of participants).
You need to find the one which corresponds to your Contact Center Agent.
For this participant element, you will have a "chats" attribute (array of chats).
Within that chat element, there is an id which corresponds to the communicationId.

In my case, I found the agent participant element corresponding to my agent. In that element (participant) I have something like this:
"chats": [
{
"state": "connected",
"id": "e90cf022-9564-4c5a-a6a8-2fbc0875f645",
"segments": [],
"held": false,
"startAlertingTime": "2019-11-06T13:38:57.876Z",
"connectedTime": "2019-11-06T13:38:59.594Z",
"provider": "PureCloud Webchat v2",
"scriptId": "c0bfc5ca-f9c8-4374-b720-f392053ffe35",
"avatarImageUrl": "https://prod-euw1-inin-directory-service-profile.s3-eu-west-1.amazonaws.com/751e1895/3ee7/4da9/9596/2a24729fffdb.jpg"
}
]

"id": "e90cf022-9564-4c5a-a6a8-2fbc0875f645" is my communicationId.

Note you can also get the same info if you know the conversationId and get conversation by id (GET /api/v2/conversations/{conversationId})

OK I followed your instructions but still get a 404. Let me provide some info

  1. GET https://api.mypurecloud.de/api/v2/conversations
  2. response -> I get the entity[0].id as the conversationId (fa1ed98e-ec21-4c75-8c30-02b8629b4b1b)
  3. I find inside that entity the participant with purpose: "agent" and get his chats[0].id (5fb0c3e3-63b1-4733-a116-76eebb3be679)
  4. POST https://api.mypurecloud.de/api/v2/conversations/chats/fa1ed98e-ec21-4c75-8c30-02b8629b4b1b/communications/5fb0c3e3-63b1-4733-a116-76eebb3be679/messages

I also tried the participant with purpose:"acd" but with no luck.

I think your problem probably comes from the fact that you are using a "Contact Center" - "Widgets" configuration/deployment with version 1.0.

The Guest Chat/Agent Chat API are used starting with Widgets deployment v1.1 or v2 or ThirdParty.
Widgets 1.0 corresponds to a former protocol.

Create a new Widget configuration with version 1.1 or version 2. And from Developer Tools - Chat, point to that widget deployment.

What I did is Admin-> Integrations-> + Integrations -> Custom Client Application and then started configuring it. I can't seem to find that version configuration you are referring to. Is it a property in the advanced section of the integration/configuration that I should add manually? Can you please refer an article about it? Thanks in advance

The configuration is in Admin -> Contact Center -> Widgets.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.