Looking for advice on sending a canned response during an active chat interaction using the .NET SDK. I’m building a backend service to push predefined answers to agents, but I keep hitting a wall.
I have the conversation ID and the participant ID. I’m trying to post a message to POST /api/v2/conversations/messaging/conversations/{conversationId}/messages. The docs say this works for SMS and web chat. Here is the payload I’m constructing in C#:
var message = new MessagingMessageRequest
{
To = new List<ParticipantAddress> { new ParticipantAddress { Id = agentParticipantId } },
Text = "Here is the standard response.",
Type = "text"
};
var response = client.MessagingApi.PostConversationsMessagingConversationsMessage(conversationId, message);
The request fails with 400 Bad Request. The error response body is vague:
{
"message": "Invalid message type for this conversation",
"code": "bad.request",
"status": 400
}
I’ve checked the Type enum. I tried "text", "application/x-ndjson", and even leaving it null. Nothing works. Is the endpoint different for real-time chat versus async messaging? I feel like I’m missing a specific header or the wrong endpoint entirely. The SDK documentation for PostConversationsMessagingConversationsMessage doesn’t explicitly mention canned responses or agent-side injection.
Also, i’m using the GenesysCloud NuGet package version 3.12.0. Could this be a version issue? I’ve verified the OAuth token has the messaging:send scope. The token is valid for other GET requests on the same conversation.
Just need to know the correct JSON structure or if I should be using a different API method like SendEvent instead. Any code examples would be appreciated. i’m stuck on this for two days now.