I am getting 401 errors for every message that the user sends thorugh webchat.
My code it's very similar to
https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/04.api/a.welcome-event
The only differnce is that for now I am getting the token in the browser something like this:
let response = await fetch('https://directline.botframework.com/v3/directline/tokens/generate',
{
method: 'POST',
headers: {
'Authorization': 'Bearer MY SECRET'
}
});
let { token } = await response.json();
The bot sends the welcome message but when the user sends any message I get the following message on webchat:
_Response status code does not indicate success: 401 (PermissionDenied)._
I am not getting any error in the console.

I am using the CDN.
Webchat connects successfully to my bot, the welcome message is displayed but any message sent from the user returns a 401 error on webchat.
This is my code:
(async function () {
let response = await fetch('https://directline.botframework.com/v3/directline/tokens/generate',
{
method: 'POST',
headers: {
'Authorization': 'Bearer MY_SERCRET'
}
});
let { token } = await response.json();
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
//Sending an event to the menu is displayed
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: {message: 'Hi'}
}
});
}
return next(action);
});
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({ token }),
store
},
document.getElementById('webchat')
);
document.querySelector('#webchat > *').focus();
})().catch(err => console.error(err));
I expect that the user can have a conversation with the bot.
Using the Iframe version to host the webchat works fine. I use direct line to connect to Twilio and works fine, my bot is developed with Composer.
[Bug]
I forgot to mention that I also tried specifying a user id when requesting the token and also calling renderWebChat but got the same result (401 error).
I also connected my javascript code to the MockBot and it works fine, so I think that I am missing some configuration either on webchat or on my bot.
This is my direct line configuration:

I am closing this since redeploying my bot fixed the issue.
Most helpful comment
I am closing this since redeploying my bot fixed the issue.