Sending canned response in chat via Python SDK returns 400

Problem

Trying to push a canned response during an active chat session. The conversation is live and the agent is connected. We’ve got the interaction ID from the WebSocket stream. The SDK documentation points to the messages endpoint, but the payload structure keeps failing.

Code

from genesyscloud.conversations_api import ConversationsApi
from genesyscloud.models import ChatMessage

client = ConversationsApi(configuration)
interaction_id = "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"

payload = ChatMessage(
 message_type="cannedResponse",
 canned_response_id="cr-98765",
 text="Thanks for waiting. How can I help today?"
)

result = client.post_conversations_chat_interactions_messages(
 interaction_id=interaction_id,
 body=payload
)

Error

Getting a straight 400 back. The response body says invalid payload: message_type must be 'text' or 'file'. I’ve tried swapping message_type to text and just passing the canned response ID in the metadata, but the system treats it like a regular agent message. It’s not applying correctly. Analytics shows the ID is valid. Maybe the endpoint is wrong.

Question

Does the Python SDK require a separate endpoint for canned responses? I keep reading about POST /api/v2/conversations/chat/interactions/{interactionId}/messages but nothing mentions how to actually trigger a canned response from the backend without the agent typing it out. The timeout keeps hitting after three retries. Just need the right JSON shape.