Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

If condition for amount of numbers

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 😀


Accepted Solutions
Dual Super User
Dual Super User

Hi @KieranHIM,


Great to hear that it worked! 😃 Happy to help.


Regarding your new question about matching codes in a list, yes that would be possible. I would add more logic to the flow to support that requirement.


But maybe it is better to open up a new thread. This way we can help you separately with that new question. Saves other people going through the different pages of this conversation thread 😁



View solution in original post

Dual Super User
Dual Super User

Hi @KieranHIM,


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




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





3. Send the charactercount back to the topic.


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:-




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😓


Dual Super User
Dual Super User

Hi @KieranHIM,


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)? 





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 😀

Dual Super User
Dual Super User

Hi @KieranHIM,


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.



Helper I
Helper I

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 😀

Dual Super User
Dual Super User

Hi @KieranHIM,

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.




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



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 😀

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'




Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

Canadian Cloud 2022 768x460.png

Register for a free PVA chatbot creation workshop.

Learn how to respond rapidly to your customers and employees at scale, using intelligent conversational chatbots.

Top Solution Authors
Users online (1,419)