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

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.

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.


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: