Looking for the cleanest way to inject a canned response into a live chat session using the Genesys Cloud JS SDK.
We’re building a supervisor assist tool. When a supervisor clicks a suggested reply, the system needs to post that text to the active conversation on behalf of the agent. The goal is to mimic the agent typing it, but automated.
I’ve been digging through the @gencloudsdk/platform-client types. The ConversationMessagingApi seems to be the right namespace, but the methods are confusing. postConversationsMessagingSessionMessage requires a sessionId and a body. The body expects a MessagingSessionMessage object.
Here’s where it gets messy. The SDK type definitions for MessagingSessionMessage don’t seem to have a direct text property that maps cleanly to a simple string post. It wants a content object with contentType and text. I’m trying to construct the payload manually because the helper methods aren’t exposing this specific flow clearly.
const messageBody = {
contentType: 'text/plain',
text: 'Here is the answer to your question.'
};
await api.postConversationsMessagingSessionMessage(sessionId, messageBody);
This throws a 400 Bad Request. The error payload says Missing required property: content. I’m clearly missing a layer of nesting or a specific field that the SDK doesn’t enforce in the types but the API demands.
Is there a specific method I’m missing? Or do I need to manually construct the full JSON structure including the id and createdTime even though those are usually server-side generated? The docs are sparse on the exact shape of the request body for programmatic message injection.
Also, does this approach work for both web chat and SMS, or is the contentType handling different for each channel? I’ve tried swapping text/plain for application/vnd.genesys.messaging.text+json but that just broke it further.
Any pointers on the correct payload shape or a better SDK method would be appreciated. Stuck on this for a day now.