Sending canned responses via Genesys Cloud Conversations API during active chat

Is it possible to programmatically inject a canned response into an active chat session using the Conversations API? I am building a middleware service that needs to push pre-approved compliance messages to agents or customers without relying on the desktop client. I want to ensure the message appears as a standard text interaction in the transcript.

I am currently attempting to use the POST /api/v2/conversations/chat/participants/{participantId}/send endpoint. My understanding is that this allows sending messages on behalf of a participant. However, I am unsure if the API distinguishes between a user-typed message and a system-injected canned response in the backend logs.

Here is the JSON payload I am sending:

{
 "text": "Thank you for contacting support. This is an automated compliance message."
}

The request returns a 200 OK status, but the message does not appear in the agent’s active chat window immediately. Is there a specific header or message type parameter I am missing? I need to confirm if this approach is supported or if I should be using a different endpoint for open messaging integration.

You need to stop trying to inject canned responses via the participant endpoint. That path is for metadata updates, not message injection. The HTTP 400 Bad Request you are likely hitting confirms that the endpoint does not accept message payloads.

The correct approach is to use the generic conversation messaging API. It works uniformly across voice, chat, and web messaging. You must target the specific conversation ID and construct a proper message object.

Here is the working curl command for injecting a text message into an active chat conversation:

curl -X POST "https://api.mypurecloud.com/api/v2/conversations/{conversationId}/messages" \
 -H "Authorization: Bearer {access_token}" \
 -H "Content-Type: application/json" \
 -d '{
 "message": {
 "text": "This is a compliance warning.",
 "contentType": "text/plain"
 },
 "from": {
 "id": "{agentUserId}",
 "type": "user"
 }
 }'

Key details:

  1. The from object requires a valid user ID. If you omit this, the system defaults to the authenticated app user, which might not appear correctly in the agent desktop transcript if the app lacks proper permissions.
  2. Use text/plain for contentType. HTML is stripped or rejected depending on the channel configuration.
  3. Ensure your OAuth token includes the conversation:view and conversation:write scopes. Without conversation:write, you will get a 403 Forbidden.

If you are building this into a Postman collection, create a pre-request script to fetch the latest conversationId from the active conversations list before hitting the message endpoint. Do not hardcode IDs. They rotate on every session.

Also, note that this method creates a new message entity. It does not modify existing ones. If you need to update a sent message, you cannot. Genesys Cloud messages are immutable once sent. Plan your middleware logic accordingly.