Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - General
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?

  • adilei Profile Picture
    on at
    Re: Event triggering onSignIn System Argument

    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?

  • Sublimion Profile Picture
    4 on at
    Re: Event triggering onSignIn System Argument

    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
    Re: Event triggering onSignIn System Argument

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Copilot Studio - General

#1
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 23

#2
Pablo Roldan Profile Picture

Pablo Roldan 21

#3
stampcoin Profile Picture

stampcoin 10

Overall leaderboard