We’ve got a Node.js service using the official SDK. Need to send a proactive notification to a guest who had a session earlier today. The docs show webchat:sendProactiveMessage but that seems to only work for brand new sessions. Is there an API endpoint to target an existing guest ID or conversation ID? We tried hitting the participants endpoint but got a 404. Any ideas?
You’re hitting a wall because the Genesys Cloud Web Chat architecture doesn’t actually support “proactive” messages to existing guest IDs in the way you’re thinking. The webchat:sendProactiveMessage event is strictly for initiating a new conversation before a guest has engaged. Once a guest ID exists, it’s tied to a specific browser session or cookie scope.
If you try to push a message to a stale guest ID, the gateway usually drops it or returns an error because the WebSocket connection is likely closed or the session has expired. There isn’t a public API endpoint like POST /api/v2/conversations/messaging/guests/{id}/messages that allows you to inject a message into an arbitrary existing guest session for security reasons. That would be a massive privacy risk.
What you can do is use the Conversations API to send a message to the conversation itself, provided you have the conversation ID and the guest is still technically “active” (or you’re sending to a messaging channel that supports async delivery like SMS or Email). For Web Chat, if the guest has closed the widget, the message won’t render unless they reopen it.
Here’s how you’d attempt to send a message to an existing conversation using the Node SDK. This assumes you have the conversationId from the previous session.
const platformClient = require('genesyscloud-purecloud-platform-client-v2');
async function sendMessageToExistingConversation(conversationId, text) {
const api = new platformClient.ConversationsApi();
// You need the 'conversation' scope in your OAuth token
// Also ensure the conversation is still active or you're using a channel that supports persistence
const payload = {
"from": {
"id": "your-bot-or-agent-id", // Usually a bot ID or agent ID
"name": "Support Bot"
},
"to": {
"id": conversationId, // Target the conversation itself
"name": "Guest"
},
"type": "text",
"text": text
};
try {
const result = await api.postConversationMessage(conversationId, payload);
console.log("Message sent with ID:", result.id);
} catch (error) {
console.error("Failed to send message:", error);
}
}
Warning: This only works if the conversation is not yet closed. If the conversation was closed by an agent or due to inactivity, you’ll get a 409 Conflict or similar error. You can’t reopen a closed Web Chat session via API.
If your goal is to notify a user who left the site, you’re better off using the Guest API to retrieve their contact details (if they provided them) and sending via Email or SMS. Or, use the “Guest API” to create a new conversation and link it to their previous history via custom attributes, but that’s not a “proactive push” to the old session.
The participants endpoint you mentioned returning 404 is likely because you’re querying a conversation that’s already terminated or the guest participant was removed. Check the conversation status first.
// Check conversation status before attempting to send
const convApi = new platformClient.ConversationsApi();
const conv = await convApi.getConversation(conversationId);
console.log("Status:", conv.status); // 'active', 'closed', etc.
If the status is closed, you’re out of luck for Web Chat. You’ll need to switch channels.
nailed it. You can’t push to a closed session, but if they’re still active, just use the standard outbound message API on the conversation ID.
POST /api/v2/conversations/webchat/{conversationId}/messages