# Triage a support inbox

Keep the messages that need a reply, and label each by kind and urgency. `filter` keeps them. `annotate` labels them.

*inbox-form.json, a file the commands read*

```
{
  "version": 1,
  "questions": {
    "kind": {
      "choose": "What kind of message is this?",
      "options": [
        "billing",
        "delivery",
        "question"
      ]
    },
    "urgency": {
      "score": "How urgent is this?",
      "levels": [
        "Routine.",
        "Soon.",
        "Immediate."
      ]
    }
  }
}
```

*Three messages need a reply, each beside its kind and its urgency from 0 to 2. The order needed tonight sits near 2, Immediate. The thank-you note drops out.*

```
question="Does this need a reply?"

cat <<'EOF' |
Please fix the wrong amount on my invoice.
Just saying thanks, no reply needed.
Order never arrived and the party is tonight.
Do you ship to Canada?
EOF
thinkthen filter "$question" --batch 1 |
thinkthen annotate inbox-form.json \
  --batch 1 --lines |
jq .
```

*Output*

```
{
  "input": "Please fix the wrong amount on my invoice.",
  "value": {
    "kind": "billing",
    "urgency": 0.58
  }
}
{
  "input": "Order never arrived and the party is tonight.",
  "value": {
    "kind": "delivery",
    "urgency": 1.96
  }
}
{
  "input": "Do you ship to Canada?",
  "value": {
    "kind": "question",
    "urgency": 0.01
  }
}
```

*exit 0*

## The functions it uses

- [filter](/functions/filter/): Keep the records where the answer is yes.

- [annotate](/functions/annotate/): Fill out a form for every record.

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