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

Announcements

News and Announcements icon
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
    Microsoft Employee 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
    Microsoft Employee 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 267

#2
Vish WR Profile Picture

Vish WR 163

#3
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 153 Super User 2026 Season 1

Last 30 days Overall leaderboard