I’m trying to inject a canned response into an active chat session using the Node.js Platform SDK. The goal is to have a bot or backend service send a pre-approved message on behalf of the agent without manual typing. I’ve got the conversation ID and the participant ID handy, and I’m constructing the payload exactly as the docs suggest for the POST /api/v2/conversations/conversations/{conversationId} endpoint.
Here’s the snippet:
const client = PlatformClient.create();
const body = {
type: "chat",
to: [{ id: agentParticipantId }],
text: "Thank you for contacting support. An agent will be with you shortly.",
cannedResponseId: "canned-uuid-from-admin-console"
};
try {
const result = await client.conversationsApi.postConversationsConversation(conversationId, body);
console.log(result);
} catch (err) {
console.error(err);
}
The request hits the server but always comes back with a 400 Bad Request. The error body is pretty vague:
{
"errors": [
{
"code": "bad_request",
"message": "Invalid input"
}
]
}
I’ve double-checked the cannedResponseId. It’s definitely valid because I can see it in the admin UI and it works when I type it manually. I’ve also tried omitting the cannedResponseId and just sending the text, which works fine for ad-hoc messages. The issue seems specific to linking that ID.
Is there a specific permission I’m missing on the OAuth token? Or maybe the payload structure for canned responses is slightly different than regular text messages? I’m running this in a local Node 18 environment with the latest genesys-cloud SDK version. Any ideas on what’s tripping up the validation layer?