#PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 4/N

El Bruno - Nov 30 '22 - - Dev Community

PowerAutomate – Flow to use Open Trivia Database questions in a Microsoft Teams bot 🤖 Series

Hi !

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.

Context

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.

![Initialize an array variable [arrAllAnswers] with the array of incorrect answers.

Add the correct answer to the array.](https://brunocapuano.files.wordpress.com/2022/11/image-15.png?w=629)

Solution

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.

sort the array variable

With this approach, we will always have the question possible answers sorted alphabetically.

Examples

Let’s take a look at a couple of examples

A true – false question

A true - false question

A 4 possible answers question, using countries !

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.

https://aka.ms/DecPowerPagesBootcamp

Starting on Dec 05

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player