# Rank the inbound leads

Drop the noise, put the buyer ready to pay first, and send each to the right sales team. `filter`, `rank`, and `choose` do it in one pipeline.

*The unsubscribe and the compliment on the talk drop out. Neither asks to buy. The team of six buying today comes first and goes to smb. The 200 seats next quarter go to enterprise.*

```
buying="Is this a buying inquiry?"
ready="Is this buyer ready to pay now?"
team="Which team should take this?"
teams=(
  enterprise
  smb
)

cat <<'EOF' |
We need 200 seats next quarter. Please send a quote.
Please remove me from this list.
Our team of six wants to buy today. How do we pay?
Loved your talk at the conference last week.
EOF
thinkthen filter "$buying" --batch 1 |
thinkthen rank "$ready" |
thinkthen choose "$team" "${teams[@]}" --lines |
jq .
```

*Output*

```
{
  "input": "Our team of six wants to buy today. How do we pay?",
  "value": "smb"
}
{
  "input": "We need 200 seats next quarter. Please send a quote.",
  "value": "enterprise"
}
```

*exit 0*

## The functions it uses

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

- [rank](/functions/rank/): Sort records by how likely the answer is yes.

- [choose](/functions/choose/): Pick one option from your list.

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