I’m trying to kick off a cobrowse session programmatically from our Node.js backend. The goal is to have the system push the cobrowse request to the agent without the customer having to click anything in the web widget first.
I’ve got the conversationId and the participantId (the customer’s). I’m using the Node.js Platform SDK (@genesyscloud/platform-client).
Here’s the snippet:
const { default: PlatformClient } = require('@genesyscloud/platform-client');
async function triggerCobrowse(conversationId, participantId) {
const platformClient = PlatformClient.createInstance();
await platformClient.loginClientCredentials({
clientId: process.env.GC_CLIENT_ID,
clientSecret: process.env.GC_CLIENT_SECRET
});
const body = {
"action": "cobrowse",
"type": "cobrowse",
"participantId": participantId,
"metadata": {
"cobrowse": {
"mode": "view",
"trigger": "api"
}
}
};
try {
const result = await platformClient.conversationsApi.postConversationsConversationsAction(conversationId, body);
console.log("Action sent:", result);
} catch (error) {
console.error("Failed:", error);
}
}
The response is always a 400 Bad Request. The error body says:
{
"errors": [
{
"message": "Invalid action type 'cobrowse' for this conversation",
"code": "invalid_action"
}
]
}
I’ve tried changing action to cobrowse_request and cobrowse_init, but those just give me “unknown action” errors. The conversation is an active Web Messaging session. I checked the docs for postConversationsConversationsAction and it lists cobrowse as a valid action type, but maybe I’m missing a prerequisite step? Do I need to add the cobrowse channel to the conversation first? Or is this just not possible via the API and I have to rely on the widget SDK to emit the event?
Running this in JST (Asia/Tokyo) if that matters for any regional quirks.