Ok so, to better explain myself, the snippet i'm referring to is this
if (props.greet)
{
if (action.type === "DIRECT_LINE/CONNECT_FULFILLED") {
console.log("Action:" + action.type);
dispatch({
meta: {
method: "keyboard",
},
payload: {
activity: {
channelData: {
postBack: true,
},
//Web Chat will show the 'Greeting' System Topic message which has a trigger-phrase 'hello'
name: 'startConversation',
type: "event"
},
},
type: "DIRECT_LINE/POST_ACTIVITY",
});
return next(action);
}
}
// Checking whether the bot is asking for authentication
if (action.type === "DIRECT_LINE/INCOMING_ACTIVITY") {
const activity = action.payload.activity;
if (activity.from && activity.from.role === 'bot' &&
(getOAuthCardResourceUri(activity))){
directline.postActivity({
type: 'invoke',
name: 'signin/tokenExchange',
value: {
id: activity.attachments[0].content.tokenExchangeResource.id,
connectionName: activity.attachments[0].content.connectionName,
token
},
"from": {
id: props.userEmail,
name: props.userFriendlyName,
role: "user"
}
}).subscribe(
(id: any) => {
if(id === "retry"){
// bot was not able to handle the invoke, so display the oauthCard (manual authentication)
console.log("bot was not able to handle the invoke, so display the oauthCard")
return next(action);
}
},
(error: any) => {
// an error occurred to display the oauthCard (manual authentication)
console.log("An error occurred so display the oauthCard");
return next(action);
}
)
// token exchange was successful, do not show OAuthCard
return;
}
} else {
return next(action);
}
return next(action);
}
What happen is this:
1. Once the connection is fulfilled, the event "startConversation" gets triggered, trying to execute the System Argument "on Conversation Start"
2. Because manual authentication in the Copilot Studio is turned on, the priority is passed to the "on Sign in" System Argument
3. the second if will catch the incoming activity that will try to display the oauthcard, and will try to execute instead a silent token exchange
4. regardless of it's execution, once the system argument "on sign in" is completed, the "startConversation" event is recovered and executed.
What i want is not to start the "startConversation" event, but to trigger the sign in so that i can later handle the greetings when i want