Hi everyone, first time here. I'm developing an SPFx component that will integrate a Copilot bot.
I used the guide present here
https://github.com/microsoft/CopilotStudioSamples/blob/master/SharePointSSOComponent/SETUP.md
Long story short, somewhere in the code there is a call to dispatch an event called "startConversation".
Doing so triggers the System Argument that triggers on conversation start.
What i want to do is to call the on login argument istead of the conversation start, because there is stuff i want to do between the authentication and the conversation start, but i can't find the name the event should have to do so.
Any help?
Maybe instead of "startConversation" try sending another custom event that will redirect to sign-in.
kind: AdaptiveDialog
beginDialog:
kind: OnEventActivity
id: main
eventName: mySignInEvent
actions:
- kind: BeginDialog
id: NQbqp8
dialog: cr148_communityQuestions.topic.Signin
I'm not sure that's necessary tough, why not simply edit the Conversation Start topic so it will send the greetings that you want?
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
What do you mean by "login argument"? Do you want sign-in to happen before any message is sent to the user?
Romain The Low-Code...
23
Pablo Roldan
21
stampcoin
10