I’m encountering an issue where my website displays the message:
“Agent is currently unavailable. It has reached its limit.”
However, when I test the same flow in Copilot Studio, it works perfectly fine.
At the start of my flow, I’m trying to send an input value from my
Angular code into one of three variables (any of them would be acceptable). The problem is that the agent isn’t accepting the input directly — whenever I try to enter or send the value (For testing), it returns the same “agent unavailable” message.
I need to pass a
user token to the agent for the
second-step authentication process.
I’ve tried three different methods to pass this token, but none of them have worked successfully.
Could you please let me know:
-
If there are any other possible ways to pass the user token to the agent directly to the agent?
-
Or if there’s any mistake in my implementation (either in the Angular code or in the agent configuration)?
My Flow
My Angular Code
createCustomStore() {
return window.WebChat.createStore(
{},
({ dispatch }: any) =>
(next: any) =>
(action: any) => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'DIRECT_LINE/POST_ACTIVITY',
meta: { method: 'keyboard' },
payload: {
activity: {
channelData: { postBack: true },
name: 'startConversation',
type: 'event',
channelId: this.userToken,
},
},
});
dispatch({
type: "WEB_CHAT/SEND_EVENT",
payload: {
name: "pvaSetContext",
value: {
"token": this.userToken
}
},
});
}
return next(action);
}
);
}
renderWebChat(token: string): void {
try {
const directLine = window.WebChat.createDirectLine({
token: token,
});
this.webChatInstance = window.WebChat.renderWebChat(
{
directLine,
styleOptions: this.styleOptions,
store: this.createCustomStore(),
userID: this.userToken,
},
this.webchatContainer.nativeElement
);
this.isReady = true;
console.log('WebChat rendered successfully');
} catch (err) {
console.error('Failed to render WebChat:', err);
}
}
As