Power Virtual Agents and PowerFX are two powerful tools that can create complex logic for bots to manipulate data. With these tools, you can create bots with more complex logic without the need for extensive development. PowerFx is a low-code language that allows users to set the value of a variable, parse strings, and use expressions in conditions.
In this article, we take a sneak peek at the capabilities and applications of Power Virtual Agents and PowerFX, including how to use variables and literal values in formulas and how to use PowerFX to set a variable as a condition.
Please refer to the comprehensive overview and formula reference.
Note:
12,567.892
. This means Power Fx parameters must be separated by commas (,).
To use a variable in a Power Fx formula, you must add a prefix to its name to indicate the variable's scope:
System.
Global.
Topic.
For example, to use the system variable Conversation.Id
in a formula, you'd need to refer to it as System.Conversation.Id
.
In addition to using variables in a PowerFx formula, you can enter literal values. To use a literal value in a formula, enter it in the format corresponding to its type. The following table lists the data types and the format of their corresponding literal values.
Type |
Format examples |
---|---|
String |
|
Boolean |
Only |
Number |
|
Table |
|
Record |
|
DateTime |
|
Choice |
Not supported |
Blank |
Only |
we'll use a Power Fx expression to store the customer's name and output it in capital letters.
Create a topic and add a Question node.
For Enter a message, enter. What is your name?
.
Under Identify, select the entity Person name.
Select the box under Save response as, and then select the variable Var1
and name it customerName
.
Under the Question node, select + and then select Set a variable value.
Please select the box under Set variable, and then select Create new and name it capsName
.
In the To value box, select the > arrow, and then select the Formula tab.
In the fx box, enter Upper(Text(Topic.customerName))
, and then choose Insert.
Hello
, select {x}, and then select capsName
.
Condition nodes can be set up to analyze more complex expressions incorporating Power Fx formulas. This will enable the bot to assess more detailed requirements before action.
In this example, the bot determines if a booking date qualifies for a discount.
To do that, it checks whether the booking date provided by the customer is 14 days or more from the current date.
When do you want to book?
.Var1
and name it bookingDate
.
Topic.bookingDate > (DateAdd (Now(), 14))
, and then choose Insert.
You qualify for a discount
.Sorry, you don't qualify for a discount
.
In conclusion, Power Virtual Agents and PowerFX are powerful tools for creating bots with more complex logic without extensive development. UsingThese tools offer a low-code solution for those who want to create bots with complex logic without the need for extensive coding knowledge. With variables and literal values in formulas and the ability to set variables and use PowerFX as a condition, you can easily manipulate data and create more advanced bots.
Also published here.
Lead Photo by Lopez Robin on Unsplash