> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fastgen.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Team Trivia App

Receive a daily TRUE or FALSE question in Slack for your team to answer.

<iframe width="674" height="315" src="https://www.youtube.com/embed/rl3uRmd0LEY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen />

#### Time Frequence

The default template will execute daily in the morning. You can adjust the timing and time zone under `Condition` in the top action block.

#### HTTP Request

The HTTP action sends a request to a public API of [https://opentdb.com](https://opentdb.com). The default template sends a request to:

```json theme={null}
https://opentdb.com/api.php?amount=1&type=boolean
```

This reques will return a single True or False question including the correct answer. The JSON will look something like this:

```json theme={null}
{
  "steps.get-trivia-question.outputs": {
    "Body": {
      "response_code": 0,
      "results": [
        {
          "category": "Entertainment: Video Games",
          "correct_answer": "True",
          "difficulty": "easy",
          "incorrect_answers": [
            "False"
          ],
          "question": "According to Greek Mythology, Atlas was an Olympian God",
          "type": "boolean"
        }
      ]
    },
    "Header": {
      "Access-Control-Allow-Origin": "*",
      "Cache-Control": "no-store, no-cache, must-revalidate",
      "Content-Type": "application/json",
      "Date": "Mon, 24 Jul 2023 18:00:26 GMT",
      "Expires": "Thu, 19 Nov 1981 08:52:00 GMT",
      "Pragma": "no-cache",
      "Server": "Apache",
      "Set-Cookie": "PHPSESSID=76e982528f82973bfdc01d6a8bbd038d; path=/",
      "Strict-Transport-Security": "max-age=31536000",
      "Vary": "User-Agent"
    },
    "Status": 200
  }
}
```

Visit [https://opentdb.com/api\_config.php](https://opentdb.com/api_config.php) to change the type and number of questions it returns.

#### Send to Slack

Since we only receive questions of the type True or False, we can use the following standardized Slack message:

> Trivia Question of the day, post your answers in the thread. TRUE or FALSE?
>
> `{{steps.get-trivia-question.outputs.Body.results.0.question}}`

In Slack, it will look something like this:

<img width="400" height="400" src="https://mintcdn.com/organa/IAAgt4Qjpzo5KMmv/images/triviascreen.webp?fit=max&auto=format&n=IAAgt4Qjpzo5KMmv&q=85&s=7e5a21b1fd1eaf42391f42eadaa7b382" data-path="images/triviascreen.webp" />

#### Modification

There are many ways of modifying this app to your preference. You can add multiple choice questions and check through an [If Condition](/actions/flow-control/if) what type of question you received to trigger different Slack messages.

Furthermore, the Open Trivia Database returns questions which contain special characters in weird formats. In order to avoid that you can change the HTTP request to:

```json theme={null}
https://opentdb.com/api.php?amount=1&type=boolean&encode=base64
```

and add a [DB Query](/actions/native-action/db-query) right after:

```sql theme={null}
select convert_from(decode({{steps.asd.outputs.Body.results.0.question}}, 'base64'), 'UTF8') 
```

to receive the right format.
