microsoft / omnichannel-chat-sdk

Headless Chat SDK to build your own chat widget against Dynamics 365 Omnichannel Services.
MIT License
42 stars 41 forks source link

Error: MessagingClientConversationJoinFailure #252

Closed akashvekariya closed 1 year ago

akashvekariya commented 1 year ago

I'm setting up omnichannel sdk for the first time and I'm getting this error message while calling startChat method. Here's my script

const express = require('express');
const bodyParser = require('body-parser');
const omnichannel = require('@microsoft/omnichannel-chat-sdk');
const cors = require('cors');
const helmet = require('helmet');
const morgan = require('morgan');

const app = express();

const omnichannelConfig = {
    orgUrl: "xxx",
    orgId: "xxx",
    widgetId: "xxx"
};

app.use(helmet());
app.use(bodyParser.json());
app.use(cors());
app.use(morgan('combined'));

const chatSdk = new omnichannel.OmnichannelChatSDK(omnichannelConfig);

app.get('/startChat', async (req, res) => {
    await chatSdk.initialize();
    await chatSdk.startChat();
    res.send('OK');
});

// starting the server
app.listen(3001, () => {
    console.log('listening on port 3001');
});

also I got the omnichannelConfig from this page's chat widget's data- attributes. app-id = widget-id and others are quite descriptive I guess. Am I doing it correctly? Screenshot 2023-09-20 at 1 18 31 PM

The error I'm getting is

listening on port 3001
/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/utils/exceptionThrowers.js:43
    throw new Error(exceptionDetails.response);
          ^

Error: MessagingClientConversationJoinFailure
    at exports.throwChatSDKError (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/utils/exceptionThrowers.js:43:11)
    at exports.throwMessagingClientConversationJoinFailure (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/utils/exceptionThrowers.js:100:13)
    at OmnichannelChatSDK.<anonymous> (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/OmnichannelChatSDK.js:637:69)
    at step (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/OmnichannelChatSDK.js:45:23)
    at Object.throw (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/OmnichannelChatSDK.js:26:53)
    at rejected (/Volumes/Work/Marketplace/Adapters/Livechat/MSDynamicsNode/node_modules/@microsoft/omnichannel-chat-sdk/lib/OmnichannelChatSDK.js:18:65)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.18.0
xTEddie commented 1 year ago

It looks like an initialization error. We'll have to investigate further to find the root cause. What is the widgetId?

akashvekariya commented 1 year ago

fd9225fc-70f1-47bf-a96b-1094a5c03452 This is the widget ID

xTEddie commented 1 year ago

omnichannel-chat-sdk is taking dependencies on different Web libraries. So, it can only be run as frontend. Based on the description, it's being run on nodejs, so it would not work.