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 / If condition for amoun...
Copilot Studio
Unanswered

If condition for amount of numbers

(0) ShareShare
ReportReport
Posted on by

Hello. Wondering if anybody can help with this. I have created a BOT, but I am struggling with an IF condition. I have created the bot on the non coding side. I basically want the BOT to give two different responses to what a user inputs. The user will be asked to confirm a number. If this number is 5 characters or above, the user will be advised one thing and if the user inputs a number using 4 characters or below, they will be advised another scenario by the BOT. Just cant seem to be able to set a condition for this, only giving me the option to set a word as a condition.

 

 

Would appreciate if somebody could provide some feedback on how to do this 😀

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Anonymous,

     

    You could use a flow action for that. In that action you could use an expression with the length function to count the number of characters. The output of that can be used in the if condition in the topic.

     

    Below is an example of that approach.

     

    1. Add an action for a flow

     

    charactercount.png

     

    2. In that flow you can use the length function in a compose.

    length(triggerBody()['text'])

     

    countnumbersflow.png

     

    3. Send the charactercount back to the topic.

    output.png

  • Community Power Platform Member Profile Picture
    on at

    Hi Dennis. Appreciate your speedy response. It looks like its going to work, but I am struggling setting the action to have it look like yours does in the example, it looks like this when I try it:-

     

     

    PowerInput.PNG

    I cant seem to get it like your example where it just has InputNumber (text) gets vaue from NumberVar (text) as its making me type a value in the NumberVar box.

     

    Do you also have an example of the flow settings I can work off please? Just want to get it set up where a number is input that is 5 or above, it gives one option, then if it gives 4 or below another, but not sure how to set this in the flow as its my first time of doing this. Sorry if this is asking too much! I think once I have this part sorted, I could then edit the length function. Hope the issue I am having makes sense and again, appreciate if you could help further on this one, thanks for your first response as I said, this looks like its going to do the job, but my inexperience in setting up the PVA Flow's is making me stumble unfortunately😓

     

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Anonymous,

     

    Happy to help you out with the rest of the configuration. Can you share a screenshot of the setup of your current flow you are using?

     

    In my example the flow has the three actions. In the first action I only have one text input field.

     

    By looking at your screenshot you might have two text inputs in your flow Power Virtual Agents trigger action (InputNumber & NumberVar)? 

     

    flowinputnumber.png

     

     

  • Community Power Platform Member Profile Picture
    on at

    HI Dennis. Again thanks for your speedy response and offer to help me. I have since looked at your flow charted and edited mine, does this look like its on the correct set up?

     

     

     

     

     

    PVA Input Flow.PNGI cant seem to get the option to edit the length input (where you have edited the expression for the trigger response), so it looks different to yours. I think once I have that sorted, then put my number in the equal to condition, should be practicaly there? Again, thanks for taking the time to help me and I hope that screen shot makes sense and you can rectify the issue.

     

     

    Kieran 😀

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Anonymous,

     

    You should be able to type the expression in the expression tab. 

     

    Btw, I am using experimental features, that is why my expression editor interface looks a bit different.

     

    expressioneditor_newerversion.png

  • Community Power Platform Member Profile Picture
    on at

    Hi Dennis. Thank you so much! That seems to have sorted it. However, When I have the condition from the Power Automate, it branches off on 'All other conditions' rather than me being able to set two conditions (one will be of the characters equal to 5, one equal to 4). I have attached the screen shot for more information.

     

    All other conditions.PNG Appreciate you getting me this far. Once I have this part sorted and can have the condition for both, I think it will be sorted. When I tested one before with the condition set to equal 5, I input a number with 5 characters in however it branched off to the all other conditions and gave the other response.

     

     

     

    Thanks 😀

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Anonymous,


    I see that your condition is not configured. Can you make sure you select the CharacterCount text variable and add 5 below the is equal to.

     

    Below is my configuration and how it looks when I test it with 5 characters.

     

    counttesttopic.png

     

    And this would be a test with 6 characters (btw, I added an additional message action in the all other conditions section).

     

    not5charactersbut6.png

  • Community Power Platform Member Profile Picture
    on at

    Thank you Dennis! Yeah I put that in and when I put a number with 5 in it stated that it was not 5 characters, but 9? Not sure how its done that when it was equal to 5. I have put the screen shots below. However, When the user puts in a number that equals 5, I want it to give a response of providing informaiton, it will say something along the lines of "this is supported by us" then if the user types a number that is 4 or less, I want it to give a response saying this is supported by another organisation, but not sure how I can do that now with the character count? If you understand what I am after and can assist with this, would be perfect as I think its nearly there, just need it to give the two response depending on the user putting a 5 character number or a 4 character number. See screen shots below to what I can now see when I tested with the bot:-

     

     

    Character Confirm.PNGCharacter Confirm 2.PNGError.PNG

    Thanks for your help Dennis, hopefully nearly there after this one. Appreciate your thorough help with this one, it means a lot 😀

  • Community Power Platform Member Profile Picture
    on at

    Apologies. I put a duplicate screen shot in on my latest reply. Below is the screen shot showing the testing with the bot where it said 'Not 5 characters, but 9'

     

     

    Error.PNG

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @Anonymous,

     

    Can you share a screenshot of your test conversation/chat with your current PVA bot? This way I can see with which numbers you are testing 😀

     

    I also need to update the flow logic. I now see your requirement is 4 characters or less. So, we probably need to add a lessOrEquals function to our length expression.

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

#2
Romain The Low-Code Bearded Bear Profile Picture

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

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard