With Power Virtual Agents, you can streamline calculations. The idea of calculator in a chatbot is that the bot will ask the user certain values. A standard formula will be created in Power Automate. It will take the user inputs for the calculation, and return the result back to the user.
The benefits of a calculator chatbot:
The example shown below uses a flow that can calculate a person’s weight on Mars.
Building the flow
Here is how the flow was created in the example above. Weight on Mars is calculated by the formula:
Weight on Mars = Weight on Earth ÷ 9.81 × 3.711
Background:
The flow will begin with Power Virtual Agents trigger. The input of Earth weight is a reference to the weight the user has provided throughout the conversation.
Add in a Compose (Data Operation) action for the first part of the calculation. It represents the first part of the formula,
Weight on Earth ÷ 9.81
The expression used is
div(triggerBody()['number'],9.81)
The next action will be another Compose (Data Operation) action to represent the last part of weight on Mars formula, Mass × 3.711
The expression used is:
mul(outputs('Find_mass'),3771)
The formula part of the flow is now complete. However, it is likely the result will have many decimal places, which does not appear user friendly. You can add a step to round your result. In the example below, the calculated weight on Mars will be rounded to two decimal places. Under the last Compose action, add a new action for Number Functions- Format number. The number being formatted is the output of the previous action.
Finally, to return the value back to Power Virtual Agents, add the result as an output in the Return value(s) back to Power Virtual Agents action.
To test out this bot, build it yourself or download the solution, check it out here on the Bot Sharing Gallery:Calculate your weight on Mars: Space-themed bot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.