Public/New-GCConversationsChatMessage.ps1

<#
.SYNOPSIS
    Sends a chat message within a chat conversation communication.

.DESCRIPTION
    Creates and sends a new chat message within an existing chat conversation and communication.
    Calls POST /api/v2/conversations/chats/{conversationId}/communications/{communicationId}/messages.

.PARAMETER ConversationId
    The unique identifier of the chat conversation.

.PARAMETER CommunicationId
    The unique identifier of the communication within the conversation.

.PARAMETER Body
    The request body containing the chat message details (body, bodyType, etc.).

.EXAMPLE
    $chatMsg = @{
        body = 'Hello, how can I help you?'
        bodyType = 'standard'
    }
    New-GCConversationsChatMessage -ConversationId 'conv-id' -CommunicationId 'comm-id' -Body $chatMsg

.NOTES
    Genesys Cloud API: POST /api/v2/conversations/chats/{conversationId}/communications/{communicationId}/messages
#>

function New-GCConversationsChatMessage {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$ConversationId,

        [Parameter(Mandatory = $true)]
        [string]$CommunicationId,

        [Parameter(Mandatory = $true)]
        [object]$Body
    )

    $endpoint = "conversations/chats/$ConversationId/communications/$CommunicationId/messages"
    return Invoke-GCApiRequest -Endpoint $endpoint -Method POST -Body $Body
}