Hello Community Members,
I hope you’re all doing well! I’ve been using Microsoft Copilot Studio to build and deploy my chatbot on our custom website app. However, I’ve encountered an issue related to web channel security.
Here are the details of the problem:
var chatWindow = document.getElementById('chatWindow');
var secret ='secret put here';
fetch('https://directline.botframework.com/v3/directline/tokens/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + secret
}
})
.then(response => response.json())
.then(data => {
var chatWindow = document.getElementById('chatWindow');
chatWindow.src='https://copilotstudio.microsoft.com/XXXXXXXXXXXXXXXXXXXXXXXXXXXX&token=' + data.token;
})
.catch(error => console.error('Error:', error));
Questions:
If it's an intermittent issue, try raising a case with support. I'm seeing a similar (older) issue here: Error with Power Virtual Agent Bot: Site Missing code 403 from https://directline.botframework.com/v3/directline/conversations · Issue #4625 · microsoft/BotFramework-WebChat (github.com)
I am trying to connect copilots in the US. (my conversation id also ends in "-us")
Are you trying to connect to copilots/bots in different regions?
I am also facing a similar issue.
Following is an example from https://github.com/microsoft/BotFramework-WebChat:
import React, { useMemo } from 'react';
import ReactWebChat, { createDirectLine } from 'botframework-webchat';
export default () => {
const directLine = useMemo(() => createDirectLine({ token: 'YOUR_DIRECT_LINE_TOKEN' }), []);
return <ReactWebChat directLine={directLine} userID="YOUR_USER_ID" />;
};
the connection is sometimes successful, however, it times out in most cases.
When I try to refresh the token, I get "Conversation not found" error
Where is this pattern taken from? i.e. a pattern where the token is being passed as a URL parameter?
The sample here should work: Customize the Web Chat canvas - Microsoft Copilot Studio | Microsoft Learn,
Specifically, this section:
const directLine = WebChat.createDirectLine({ domain: new URL('v3/directline', directLineURL), token });
// Sends "startConversation" event when the connection is established.
const subscription = directLine.connectionStatus$.subscribe({
next(value) {
if (value === 2) {
directLine
.postActivity({
localTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
locale,
name: 'startConversation',
type: 'event'
})
.subscribe();
// Only send the event once, unsubscribe after the event is sent.
subscription.unsubscribe();
}
}
});
WebChat.renderWebChat({ directLine, locale, styleOptions }, document.getElementById('webchat'));
Michael E. Gernaey
169
Super User 2025 Season 1
Romain The Low-Code...
150
sandeep_angara
75