Sending messages in an agent-initiated webchat interaction

I cannot send any message in a chat interaction that has already started.

First, I created a chat interaction:

POST /api/v2/conversations/chats
Body:
{
"queueId": "232f682a-c300-4656-86eb-e842bbc1636c",
"provider": "Chat System",
"customerName": "User 1"
}
Response:
{
"id": "3dc8557e-6245-4bd3-9a8c-a2c7344c9e24",
"otherMediaUris": [],
"selfUri": "/api/v2/conversations/chats/3dc8557e-6245-4bd3-9a8c-a2c7344c9e24"
}

With that, the interaction arrives correctly at the frontend, and the Agent can handle the interaction.
image

Following the instructions in this post, I made a new request to obtain CommunicationID:

GET /api/v2/analytics/conversations/3dc8557e-6245-4bd3-9a8c-a2c7344c9e24/details

Response
{
"conversationId": "3dc8557e-6245-4bd3-9a8c-a2c7344c9e24",
"conversationStart": "2021-03-22T05:03:31.512Z",
"originatingDirection": "inbound",
"divisionIds": [
"2ce2cb60-c191-4301-aebd-b874352bdd18"
],
"participants": [
{
"participantId": "e42cc774-4008-4eb2-9e0a-a2b4bb45223e",
"participantName": "User 1",
"purpose": "external",
"sessions": [
{
"mediaType": "chat",
"sessionId": "213c8bdf-d2e3-4c0e-a1ae-e372cb31cb9e",
"direction": "inbound",
"roomId": "NONE",
"segments": [
{
"segmentStart": "2021-03-22T05:03:31.512Z",
"segmentType": "interact",
"conference": false
}
],
"metrics": [
{
"name": "nConnected",
"value": 1,
"emitDate": "2021-03-22T05:03:31.512Z"
}
],
"provider": "Chat System"
}
]
},
{
"participantId": "7c986ef3-4ec7-45cc-b86d-45eba847927b",
"participantName": "SMS_Test",
"purpose": "acd",
"sessions": [
{
"mediaType": "chat",
"sessionId": "3fbc7b0a-bafd-417b-99dd-8330fe67dfe3",
"direction": "inbound",
"roomId": "NONE",
"peerId": "213c8bdf-d2e3-4c0e-a1ae-e372cb31cb9e",
"segments": [
{
"segmentStart": "2021-03-22T05:03:31.513Z",
"segmentEnd": "2021-03-22T05:09:55.331Z",
"queueId": "232f682a-c300-4656-86eb-e842bbc1636c",
"disconnectType": "transfer",
"segmentType": "interact",
"conference": false
}
],
"metrics": [
{
"name": "nOffered",
"value": 1,
"emitDate": "2021-03-22T05:03:31.513Z"
},
{
"name": "tAcd",
"value": 383818,
"emitDate": "2021-03-22T05:09:55.331Z"
}
],
"provider": "Chat System",
"remote": "User 1",
"requestedRoutings": [
"Standard"
],
"usedRouting": "Standard",
"selectedAgentId": "650e52ea-35d0-45d3-8047-4263cef91ab3"
}
]
},
{
"participantId": "e49a1dd7-c98f-4117-a84a-972b0501cffa",
"userId": "650e52ea-35d0-45d3-8047-4263cef91ab3",
"purpose": "agent",
"sessions": [
{
"mediaType": "chat",
"sessionId": "053889e8-427d-43a3-ade4-1b0f371f90c6",
"direction": "inbound",
"roomId": "NONE",
"peerId": "213c8bdf-d2e3-4c0e-a1ae-e372cb31cb9e",
"segments": [
{
"segmentStart": "2021-03-22T05:08:00.281Z",
"segmentEnd": "2021-03-22T05:08:30.399Z",
"queueId": "232f682a-c300-4656-86eb-e842bbc1636c",
"disconnectType": "system",
"segmentType": "alert",
"conference": false
}
],
"metrics": [
{
"name": "tAlert",
"value": 30118,
"emitDate": "2021-03-22T05:08:30.399Z"
},
{
"name": "tNotResponding",
"value": 30118,
"emitDate": "2021-03-22T05:08:30.399Z"
}
],
"provider": "Chat System",
"remote": "User 1",
"requestedRoutings": [
"Standard"
],
"selectedAgentId": "650e52ea-35d0-45d3-8047-4263cef91ab3"
}
]
},
{
"participantId": "746eb0e1-2247-400f-bd11-4042a9d6322b",
"userId": "650e52ea-35d0-45d3-8047-4263cef91ab3",
"purpose": "agent",
"sessions": [
{
"mediaType": "chat",
"sessionId": "f80dddaf-30b0-465c-a33d-6b014fbbcf8e",
"direction": "inbound",
"roomId": "NONE",
"peerId": "213c8bdf-d2e3-4c0e-a1ae-e372cb31cb9e",
"segments": [
{
"segmentStart": "2021-03-22T05:09:52.203Z",
"segmentEnd": "2021-03-22T05:09:55.327Z",
"queueId": "232f682a-c300-4656-86eb-e842bbc1636c",
"segmentType": "alert",
"conference": false
},
{
"segmentStart": "2021-03-22T05:09:55.327Z",
"queueId": "232f682a-c300-4656-86eb-e842bbc1636c",
"segmentType": "interact",
"conference": false
}
],
"metrics": [
{
"name": "nOverSla",
"value": 1,
"emitDate": "2021-03-22T05:09:55.327Z"
},
{
"name": "tAlert",
"value": 3124,
"emitDate": "2021-03-22T05:09:55.327Z"
},
{
"name": "tAnswered",
"value": 383818,
"emitDate": "2021-03-22T05:09:55.327Z"
}
],
"provider": "Chat System",
"remote": "User 1",
"requestedRoutings": [
"Standard"
],
"usedRouting": "Standard",
"selectedAgentId": "650e52ea-35d0-45d3-8047-4263cef91ab3"
}
]
}
]
}

From what I understand from the post, the sessionID of the first participant is the communicationID
So I try to send the first message programmatically

POST /api/v2/conversations/chats/3dc8557e-6245-4bd3-9a8c-a2c7344c9e24/communications/213c8bdf-d2e3-4c0e-a1ae-e372cb31cb9e/messages

Body
{
"body": "Hello World"
}

Response
{
"message": "Not Found",
"code": "chat.error.not.found",
"status": 404,
"messageWithParams": "Not Found",
"messageParams": {},
"contextId": "35699c57-5927-44ef-aad2-1d584f1ec7bd",
"details": [],
"errors": []
}

Why can't I find the chat?

I performed all of these tests using API Explorer. The behavior of the frontend is as expected (Where the agent does not send and receive messages through Genesys Cloud, and can only perform administrative tasks such as associating profiles and choosing the wrapup code). All messages that will be sent through this development will be done via API.

Thanks in advance! :slightly_smiling_face:

Hello,

The POST /api/v2/conversations/chats is to create a 3rd party chat.
Consider this as a "work-item" of type chat - meaning that the media channel (exchange of messages between users) does not go through Genesys Cloud and is not managed by Genesys Cloud (but by a 3rd party chat system).
See here for some information on 3rd party chat

That's why your attempt to send a message in the chat conversation, with POST /api/v2/conversations/chats/{conversationId}/communications/{communicationId}/messages, is failing.
You will be able to send a message in the chat conversation only if it is a real/native Genesys Cloud chat.

If you want to create a chat session with Genesys Cloud (Chat v2), you have to use the Guest Chat API [API used on "public" side - customers to Genesys Cloud].
Or you can use the built-in Widgets v2 UI.

As a note, you will only be able to send a message in a Chat v2 conversation if you are an active participant of that conversation (user credentials to obtain the authorization token + user is connected to this chat conversation as a participant/member).

Regards,

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