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 😀
Solved! Go to Solution.
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.
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'.
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.
Hi Dennis.
I have updated it to exactly how you have it apart from making changes to text I want to apply -
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?
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.
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:-
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:-
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'))
Topic canvas:
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:-
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
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?
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.
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.
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.
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:-
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:-
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
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'.
Keep up to date with current events and community announcements in the Power Virtual Agents community.
A great place where you can stay up to date with community calls and interact with the speakers.
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |