# `@question`: a saved question that six functions accept.

*refund.json, a file the examples read*

```
{
  "decide": "Does the customer ask for a refund?",
  "true": "The customer asks for money back.",
  "false": "Anything else, such as a cancellation or thanks.",
  "threshold": "0.2:0.8"
}
```

*The saved question answers true for a plain request for money back.*

```
cat <<'EOF' |
I would like to return this and get my money back.
EOF
thinkthen decide @refund.json
```

*Output*

```
true
```

*exit 0: yes*

Save one question in a JSON file. Pass it as `@FILE` to decide, choose, tag, score, filter, or rank. Every command that reads the file then asks the same question.

## Read the answer

A band in the file marks the middle answers not sure. Send those to a person.

| Exit code | What it means |
| --- | --- |
| 5 | the file could not be read, is not one JSON object, or breaks a rule |
| 2 | the command names the wrong verb for the file |

## Call it from your language

The Bash example opens this page.

No Python sample for `question-file`.

```
import polars as pl
import thinkthen as tt

question = "Does the customer ask for a refund?"
refund = tt.question(decide=question, threshold=(0.2, 0.8))
tickets = pl.DataFrame({
    "body": [
        "Please refund my order. It arrived broken.",
        "Thanks for the quick help yesterday!",
        "I want to send this back.",
    ],
})
is_refund = tt.decide(refund, tickets["body"]).value
tickets = tickets.with_columns(is_refund=is_refund)
assert tickets["is_refund"].to_list() == [True, False, None]
```

No pandas sample for `question-file`.

```
import assert from "node:assert/strict";
import * as tt from "thinkthen";

const question = "Does the customer ask for a refund?";
const refund = tt.question({
  decide: question,
  threshold: [0.2, 0.8],
});
const sendBack = "I want to send this back.";
const isRefund = (await tt.decide(refund, sendBack)).value;
assert.equal(isRefund, null);
```

```
require "thinkthen"

question = "Does the customer ask for a refund?"
refund = ThinkThen.question(
  decide: question,
  threshold: 0.2..0.8
)
send_back = "I want to send this back."
is_refund = ThinkThen.decide(refund, send_back).value
raise unless is_refund.nil?
```

```
library(thinkthen)

question <- "Does the customer ask for a refund?"
refund <- tt_question(
  decide = question,
  threshold = c(0.2, 0.8)
)
texts <- c(
  "Please refund my order. It arrived broken.",
  "Thanks for the quick help yesterday!",
  "I want to send this back."
)
is_refund <- tt_decide(refund, texts)$value
stopifnot(identical(is_refund, c(TRUE, FALSE, NA)))
```

```
use thinkthen::{Answer, Engine, Question};

let tt = Engine::from_env()?;
let question = "Does the customer ask for a refund?";
let refund = Question::decide(question)?.band(0.2, 0.8)?;
let send_back = "I want to send this back.";
let is_refund = tt.decide(&refund, send_back)?.into_value();
assert_eq!(is_refund, Answer::Unsure);
```

Put this code inside `fn main() -> Result<(), Box<dyn std::error::Error>>` and end it with `Ok(())`. `main` returns a `Result`, so `?` compiles.

No C sample for `question-file`.

No C++ sample for `question-file`.

No Objective-C sample for `question-file`.

No COBOL sample for `question-file`.

No Ada sample for `question-file`.

No Java sample for `question-file`.

No Kotlin sample for `question-file`.

No Scala sample for `question-file`.

No C# sample for `question-file`.

No Go sample for `question-file`.

No Swift sample for `question-file`.

No Zig sample for `question-file`.

No PHP sample for `question-file`.

No Dart sample for `question-file`.

```
LOAD './thinkthen.duckdb_extension';

SELECT
    trim(body, chr(10)) AS body,
    thinkthen_decide('@refund.json', body) AS is_refund
FROM (VALUES
    ('I would like to return this and get ' ||
     'my money back.' || chr(10)),
    ('I want to send this back.' || chr(10))
) t(body);
```

*What DuckDB printed*

```
body|is_refund
I would like to return this and get my money back.|true
I want to send this back.|NULL
```

```
.load ./thinkthen

WITH t(body) AS (VALUES
    ('I would like to return this and get ' ||
     'my money back.' || char(10)),
    ('I want to send this back.' || char(10)))
SELECT
    thinkthen_decide('@refund.json', body) AS is_refund,
    trim(body, char(10)) AS body
FROM t;
```

*What SQLite printed*

```
1|I would like to return this and get my money back.
|I want to send this back.
```

No PostgreSQL sample for `question-file`.

[Arguments, options, and more examples](/reference/functions/question-file/)

On GitHub: [github.com/botassembly/thinkthen](https://github.com/botassembly/thinkthen)
