cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KieranHIM
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 😀

29 REPLIES 29
Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

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.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

I have changed the setup slightly. Can you have a look and try if the setup below works for you?

 

1. In the compose action I am using a updated expression.

if(lessorequals(length(triggerBody()['text']), 4), 'Organisation A', if(equals(length(triggerBody()['text']), 5), 'Organisation B', '6 characters or more'))

 

In that expression I am checking if the length is less or equal to 4. If this is true I am outputting Organisation A. When false I am checking if the length equals 5. If that is true I am outputting Organisation B. For a length that is higher than 5 I am outputting the text '6 characters or more'.

 

lessorequals4.png

 

2. In the topic I have updated the conditions. Instead of checking for a number we can now check for the name of the Organisation. 

 

 

counttopic_v2.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Hi Dennis.

 

 

I have updated it to exactly how you have it apart from making changes to text I want to apply - 

if(lessorequals(length(triggerBody()['text']), 4), 'This appears to be an Emis CDB Org code supported by Emis help. Please contact them directly for more assistance with this one', if(equals(length(triggerBody()['text']), 5), 'This looks like one of our community codes''6 characters or more'))
 
So, that is basically saying that if they type something in with 5 characteres, it will advise them its a code supported by community. Then, if they type in a 4 character one, it says contact Emis. However, please see below screen shot of it just going to the other condition on the right hand side no matter what I put in (I cant delete this condition either, it doesnt let me!!!):-
 
 
Unwanted Condition Being selected.PNG
I feel I am so close to what I want here largely thanks to your help. Just hope this makes sense of what I want, just not sure why that 'All other conditions' one is there and why that one is being selected, even though I am putting in a code with 5 characters in, why should go to the message '
This looks like one of our community codes'
 
Thanks again for this Dennis as I said, hopefully you can see what I mean and how to prevent it from going to the other condition, even though it should be going to the condition on the left that is equal to 5.
 
 
Kieran😀
Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

You are very close. I see you are still using the numbers in the condition actions. What you are outputting in the expression in the flow needs to match what you are checking in the pva condition action.

 

Below is a screenshot, hope this makes sense?

 

theseneedtomatch.png

 

You can use whatever you want in your expression in flow and the condition in your topic. As long as those values match. See also in my example below.

 

thesematch_example.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


KieranHIM
Helper I
Helper I

Hi Dennis. Thank you for that, I have fixed that and the expression in the condition matches the expression from the flow. However, please see below, I am inputting a 5 digit number and its still going to the unwanted condition on the right hand side, not the one on the left:-

 

Unwanted Condition Being selected.PNG

Not sure why its doing it, as the expression seems to be correct in terms of what it is to state when a 5 digit number is put in (Should go to the left hand condition stating that it is a supported community code. Sorry if this is becoming a pain and I am still doing something wrong, but not sure how it can be wrong when all what you have suggested is now in place. The expression I have is:-

 

 

if(lessorequals(length(triggerBody()['text']), 4), 'This appears to be an Emis CDB Org code support by Emis Web. Please contact them directly.', if(equals(length(triggerBody()['text']), 5), 'This looks like one of our community codes''6 characters or more'))
 
Again appreciate your support so far with this, its got me much further than I thought I would be at this stage, just hoping its one last little thing now that retifies this! 😀

 

Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

I would keep it a bit simpler by replacing 'Go to CharacterCount' by just the text you want to show. I would also just use the numbers instead of the long text in both the flow expression and the condition action. This also makes it a bit more managable.

 

Can you try the setup below?

 

Flow expression:

if(lessorequals(length(triggerBody()['text']), 4), '4', if(equals(length(triggerBody()['text']), 5), '5', '6 characters or more'))

 

flowexpression.png

 

Topic canvas:

 

hardcodetext_pva.png

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


KieranHIM
Helper I
Helper I

Hi @Expiscornovus 

 

 

Thank you for that, I have ammended that and have changed the expression to what you have said and updated the fields on the canvas. However, it was still going to the other condition on the right even though I met the crietia. So, I removed this condition and now it just gets stuck:-

 

Result.PNGInput.PNG

I have also inserted the flow chart details to see if I am doing something wrong? I tihnk all what you have said is now in there, just not sure why its still not recognising the condition is being met and giving the correct message response.

 

 

Thanks again Dennis, hopefully you spot the error and it can be sorted, appreciate your help I know I have mentioned this a LOT already 🙂

 

 

Kieran

Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

It looks like there is a space character just before the fx button in the compose action. If there is a space character in that compose action, can you remove that?

 

And I also have some additional questions for troubleshooting.

 

1. What is the trigger phrase for your topic?

In my example that is CountNumbers. That is the first thing I will type to make sure the bot knows which topic I want to interact with. I can't see that in your test screenshots. Are you typing the trigger phrase first before you enter the number?

 

countnumbers_triggerprhase.png

 

2. Can you add another compose action and add the inputnumber field to it?

Via peek code we can check if the internal name of your field is the same as in the expression we are using. Potentially it could be different and that can be a root cause for your wrong CharacterCount output.

 

secondcompose.pngpeekcode_text.pngpeekcode_textfield.png

3. Can you peek code the current compose action?

Like mentioned earlier in this post. It looks like there is a space character just before the expression.

 

othercompose_peekcode.png

 

4. Can you have a look at the history of the flows?

In the history it is also easy to spot what the system is trying to process.

 

flowhistory_check.png

 

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


KieranHIM
Helper I
Helper I

Hi Dennis.

 

 

So sorry, I have rectified that now and added in the new compose. My trigger phrase is going to be numbers that we support, as it will be users asking questions in relation to that. See below:-

 

Snap1.PNG

So, above has 5 codes for now for testing purposes and this error is happening even though I am putting one of the 5 digit codes in, which is where it then asks me. I am going to have all codes there for community and for the 4 digit ones supported by Emis Web (if this makes sense?) so as long as thats being met, it will ask if the user is wanting to discuss an Emis CDB ORG code.

 

Below, is the new look of the compose with the additional one you have mentioned:-

 

snap2.PNGSnap1.PNG

The screen shots are the opposite way around there sorry, but hope it shows the full flow chat, as well as my expression which you provided. Do you think in theory this should now work if I am especially putting in trigger phrases (but it should work regardless with the 5 or 4 characters being entered with the Character Count being met). Sorry if I have waffled on there, hope I make sense.

 

 

Thanks Dennis, look forward to hearing back 😀

 

Kieran

Expiscornovus
Super User
Super User

Hi @KieranHIM,

 

If the trigger phrase is the same as the actually code this might confuse the bot. When you retype the code in response to 'Can you please reconfirm the Org code' question the bot might start over again and will ask the first question again. 

 

Typically a trigger phrase is something a user enters in the chat window to start a conversation with the bot. I would use something random like 'I need help with Emis CDB' or even just one word like 'Emis'.



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements
Power Virtual Agents News & Announcements

Power Virtual Agents News & Announcements

Keep up to date with current events and community announcements in the Power Virtual Agents community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Virtual Agents Community Blog

Power Virtual Agents Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (4,473)