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 / Get external variables
Copilot Studio
Unanswered

Get external variables

(0) ShareShare
ReportReport
Posted on by 36

Is there a way to get variables from the website where I publish the bot? That is, the client is already logged in on the website and suddenly starts using the bot, so as not to have to ask him for his name again, for example, since he is already logged in, is there a way to collect that data?

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

    See if this helps: https://learn.microsoft.com/en-us/microsoft-copilot-studio/authoring-variables-bot?tabs=webApp#set-a-global-variables-value-from-external-sources

     

    BTW: if it's actually an authentication flow you are looking to implement, it is safer to pass a token, not details like name, etc.

  • ElenaAA Profile Picture
    36 on at

    Thanks for your reply. I have been testing and as I understand, in the call to the bot from the web I have to pass the parameter, for example, after the code I had, I put "&ClientID=5". Then in copilot I have to create the variable and put it with the same name as Global and that it can receive external data, but it asks me to assign a value, what should I put

    ElenaAA_0-1710414803082.png

    Saludos y gracias

  • adilei Profile Picture
    on at

    I guess it's not that clear in the docs - you need a question node in order to "capture" the incoming value:

     

     

    adilei_1-1710429789302.png

     

  • ElenaAA Profile Picture
    36 on at

    But then if I ask it as a question, why do I send the variable through the url to the bot? What I supposedly want is that when the client opens the bot without asking anything, he directly sends a variable to the bot and with this variable, with internal processes, the bot responds one thing or another. For example, I don't want to ask the client again what his name is if he has already logged in to the website.

  • Javiavan Profile Picture
    30 on at

    I have the same problem as you, ElenaAA. I've been researching for several days and I've looked at Microsoft's documentation twice. If at any time you manage to solve it, please share

  • adilei Profile Picture
    on at

    The question node is just a way to capture an incoming value. When the conversation starts, the question will be skipped and won't be presented to the user.

  • ElenaAA Profile Picture
    36 on at

    The question is omitted, okay. But the client will have to write something to retrieve the variable, right? And at some point I will have to make that assignment of the Clientid variable of the url with the Global Clientid variable created, right?

    I have also tried what you mentioned and it won't let me create a blank question.

    ElenaAA_1-1710449549165.png

     

  • adilei Profile Picture
    on at

    For everyone on this thread, here is the complete solution:

     

    1. Add a question node to your Conversation Start topic that will populate a global variable. Allow setting the variable from external sources.

     

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnConversationStart
     id: main
     actions:
     - kind: Question
     id: question_ZOc4Os
     interruptionPolicy:
     allowInterruption: true
    
     variable: init:Global.myParam
     prompt: external variable
     entity: StringPrebuiltEntity
    
     - kind: SendActivity
     id: sendActivity_Yfykys
     activity: "Your value for myParam is: {Global.myParam}"

     

     

    2. When embedding the copilot in your website, append a parameter with the same name as your global variable to the copilot URL.

     

    For example:

     

     

    https://web.powerva.microsoft.com/environments/env_id/bots/bot_id/webchat?__version__=2&myParam=myValue

     

     

    When the conversation starts, the question will be skipped, and the variable will be populated from the URL parameter:

     

    adilei_1-1710449831698.png

     

     

  • adilei Profile Picture
    on at

    The question node itself will assign the value, and the user will not have to write anything - as the question is embedded in "Conversation Start". It's fine if the question isn't empty because it won't be shown. In short, try the solution I posted here, it works, I promise 🙂

  • Javiavan Profile Picture
    30 on at

    Thank you very much, Adilei, I'm going to try it

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 261 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

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

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard