D365 Transcript Analytics not working
xTEddie opened this issue · 1 comments
xTEddie commented
D365 Transcript Analytics not working
xTEddie commented
Root cause is ChannelId-lcw
& FromCustomer
tags were not sent on sending message
Using BF-WebChat
on v1
chats, we need to intercept the activity
data on DIRECT_LINE/POST_ACTIVITY_PENDING
, then add these additional tags.
import {createStore} from 'botframework-webchat';
const channelIdTag = `ChannelId-lcw`;
const customerMessageTag = `FromCustomer`;
const sendDefaultMessagingTagsMiddleware = () => (next) => (action) => {
const condition = action.type === "DIRECT_LINE/POST_ACTIVITY_PENDING"
&& action.payload
&& action.payload.activity
&& action.payload.activity.channelData;
if (condition) {
if (!action.payload.activity.channelData.tags) {
action.payload.activity.channelData.tags = [];
}
if (!action.payload.activity.channelData.tags.includes(channelIdTag)) {
action.payload.activity.channelData.tags.push(channelIdTag);
}
if (!action.payload.activity.channelData.tags.includes(customerMessageTag)) {
action.payload.activity.channelData.tags.push(customerMessageTag);
}
}
return next(action);
};
const store = createStore(
{}, // initial state
sendDefaultMessagingTagsMiddleware
);