PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 Series
- Intro to Open Trivia Database API
- How to process the API Response and send a question to Teams
- How to validate the user response in teams with the Trivia Question correct answer
- Sort and mix the possible answers to the question
- Trigger the flow from a new message in a Teams channel, and validate the trigger start
- Live Reactor Event – Let’s build this online !
In previous posts we request a Trivia quesion using the Open Trivia Database API, and sent the question as a message using Teams Flow Bot.
The process of the quesion is fine, however, the way that we process the answers has a flaw. Let’s take a look at steps in the current flow.
- Initialize an array variable [arrAllAnswers] with the array of incorrect answers.
- Add the correct answer to the array.
Once you answer a couple of questions, you may detect that the correct answer is always at the end. It’s time to think for a creative solution.
At the beggining I think in a weird solution: we have several options to work with arrays, so we may create a series of steps to mix the array.
At the end, I choose to use the simple solution: sort the array. Yes, we have a sort function, and that will be enough.
With this approach, we will always have the question possible answers sorted alphabetically.
Let’s take a look at a couple of examples
A true – false question
A 4 possible answers question, using countries !
\We are almost there ! However, we can improve still this flow a lot 😀
And important: Join me in this 2-week FREE program @MSFTReactor
and we will learn together about Microsoft Power Pages.
We will also cover fundamentals of Power Pages architecture, components, features, and tooling.
Starting on Dec 05
More posts in my blog ElBruno.com.