param( [Parameter(Mandatory=$true)] [string]$Message, [Parameter(Mandatory=$false)] [string]$ServerUrl = "http://localhost:8880", [Parameter(Mandatory=$true)] [string]$AppToken ) [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $body = @{ text = $Message } | ConvertTo-Json -Depth 3 $headers = @{ "Content-Type" = "application/json; charset=utf-8" "X-App-Token" = $AppToken } try { $response = Invoke-RestMethod -Uri "$ServerUrl/send" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) -Headers $headers Write-Host "Message sent successfully. Message ID: $($response.message_id)" exit 0 } catch { Write-Error "Failed to send message: $_" exit 1 }