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 :
Copilot Studio
Answered

Default dates

(1) ShareShare
ReportReport
Posted on by 23
Hi All
 
I have created an agent that has a set of flows that pull data from a SQL database.
Those flows need a Start Date and End Date and the name of City.
On the instructions I have specified that if the user does not mention any dates the virtual agent should by default go to the last 7 days up to yesterday.
However this does not always work and the virtual agent still asks for the Start Date and the End Date.
 
I am wondering if making these variables not required would make the instructions prevail always.
If that is not the case or if it was not the best way forward I am wondering if creating a specific topic would help, but I am not sure how this would work
 
Thank you
 
I have the same question (0)
  • Nivedipa-MSFT Profile Picture
    Microsoft Employee on at
    Hello  - Thanks for bringing this issue to our attention. 

    While the agent's instructions guide the LLM’s behavior, any flow input parameters marked as required will always be prompted for before the flow runs, regardless of the instructions. The orchestration layer ensures that required inputs are collected independently from the LLM’s logic.

    Recommended Approach (Combination)1. Set Start Date and End Date as optional in your flow

    Making these inputs optional allows your instructions to function as intended, since the agent won’t pause execution waiting for those values.

    2. Assign default values within the Power Automate flow

    Rather than having the agent provide default dates, set up your flow to:

    • Check if StartDate and EndDate are empty or null
    • If they are, set StartDate = utcNow() - 7 days and EndDate = utcNow() - 1 day
    • This ensures defaults are always applied correctly, regardless of agent behavior

    3. Keep your instructions as backup

    Instructions for the agent, such as “use the last 7 days up to yesterday if no dates are mentioned,” still help by reducing unnecessary follow-up questions. However, the flow should define the default logic.

    Should you create a dedicated topic?

    A dedicated topic can be useful, but it’s not required if you follow the steps above. It may help when you want to trigger flows with phrases like “show me data for [City],” and explicitly set date defaults using message or variable nodes before calling the flow, giving you more direct control over the process.


    If you found the information above helpful, I would appreciate it if you could share your feedback.

    Your feedback is important to us. Please rate us:

    🤩 Excellent 🙂 Good 😐 Average 🙁 Needs Improvement 😠 Poor

  • Suggested answer
    Beyond The Platforms Profile Picture
    145 on at

    Hi Ivan!

    Your instinct is right — relying only on the agent's instructions for default date logic is not reliable, because by default, each input is set to "Dynamically fill with the best option": the agent tries to populate the value from available context, and if no appropriate value is found, it generates a question to ask the user. Microsoft Learn Instructions alone don't guarantee the fallback will always be applied consistently.

    Here are the two recommended approaches:

     

    Option 1 — Override the input directly with a Power Fx formula (simplest fix)

    On your flow's tool configuration in Copilot Studio, for the StartDate and EndDate inputs:

    Select "Set as a value" under How will the agent fill this input? and enter the desired value. Microsoft Learn You can use a Power Fx formula to compute yesterday and 7 days ago dynamically:


    • EndDateText(DateAdd(Today(), -1, TimeUnit.Days), "yyyy-MM-dd")

    • StartDateText(DateAdd(Today(), -7, TimeUnit.Days), "yyyy-MM-dd")


    •  

    This makes the default deterministic — the agent never needs to ask the user for these values unless you explicitly want it to.

     
     

    Option 2 — Create a dedicated Topic (more control)

    Build a topic that triggers when the user asks for data without specifying dates. Inside the topic:


    1. Add a Condition node: check if the user mentioned a date in their message

    2. If no date → use a Set Variable node with the Power Fx formulas above to assign StartDate and EndDate

    3. If date mentioned → use a Question node to capture it

    4. Then call the flow with the pre-populated variables

    5.  
     

    When you define a tool in Copilot Studio, the agent orchestrator handles input collection at runtime — but you can also call tools explicitly from within topics, giving you full control over how inputs are filled. Microsoft Learn

     
     

    One important note on date types

    You can't configure agent flow inputs as Date & Time directly — doing so causes a TriggerInputSchemaMismatch error. The recommended pattern is to pass dates as strings and handle the conversion inside the flow itself. Veronique\\\'s Blog Make sure your flow inputs are typed as Text, not Date.

     
     

    Recommendation: Start with Option 1 — it's the quickest fix and removes the ambiguity entirely. Use Option 2 if you need to ask the user for dates when they explicitly mention them while keeping the default otherwise.

     

    Hope this helps!
    Paolo


    Did this solve your issue? → Accept as Solution
    👍 Partially helpful? → Click "Yes" on "Was this reply helpful?" or drop a Like!


    Want more tips on Power Platform & AI? Follow me here:

    🔗 LinkedIn: https://www.linkedin.com/in/paoloasnaghi/
    ▶️ YouTube: https://www.youtube.com/@BeyondThePlatforms
    📸 Instagram: https://www.instagram.com/beyond_the_platforms/
    🌐 Website: https://www.beyondtheplatforms.com/


     

  • Ivan_ Profile Picture
    23 on at
    So then if I understand this correctly if I go the flow and apply this formula for Start Date at initialise variable:
    if(
      empty(triggerBody()?['text_1']),
      formatDateTime(addDays(utcNow(), -7), 'yyyy-MM-dd'),
      triggerBody()?['text_1']
    )
    and the same thing when it comes to Set Variable
    That should work if no value was provided for start date provided that I have ticked that variable as not required. Is this correct?
    Thank you
     
  • Verified answer
    Valantis Profile Picture
    3,406 on at
    Hi @Ivan_,
     
    Yes that expression is correct. As long as the input is marked as not required in Copilot Studio, the trigger will pass an empty or null value when the user doesn't provide a date, and the empty() check in your flow will catch that and apply the 7-day default.

    One thing to double-check: make sure the Initialize Variable action uses the expression tab (not dynamic content) when entering that formula, otherwise Power Automate won't evaluate it correctly.

    Also apply the same pattern to End Date using addDays(utcNow(), -1) for yesterday.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 618

#2
Haque Profile Picture

Haque 147

#3
Vish WR Profile Picture

Vish WR 140

Last 30 days Overall leaderboard