web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Event triggering onSig...
Copilot Studio
Unanswered

Event triggering onSignIn System Argument

(0) ShareShare
ReportReport
Posted on by 4

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?

Categories:
I have the same question (0)
  • adilei Profile Picture
    on at

    What do you mean by "login argument"? Do you want sign-in to happen before any message is sent to the user? 

  • Sublimion Profile Picture
    4 on at

    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

  • adilei Profile Picture
    on at

    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?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 255 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 205 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard