Skip to content

Quickstart

Install ThinkThen, set your key, and ask your first question about a customer message.

On macOS or Linux:

Terminal window
curl -fsSL https://thinkthen.dev/install.sh | sh

In Windows PowerShell:

Terminal window
irm https://thinkthen.dev/install.ps1 | iex

Open a new terminal, then check that it worked:

Terminal window
thinkthen --version

Output

thinkthen 0.2.0

Installation covers Homebrew, Cargo and downloads.

ThinkThen sends each question to TypeSafe's System One service, which bills your TypeSafe account for each call. Get a key on the TypeSafe keys page, then set it in your shell:

Terminal window
export THINKTHEN_API_KEY='your key'

In Windows PowerShell:

Terminal window
$env:THINKTHEN_API_KEY = 'your key'

To use OpenAI or your own server instead, see Configuration.

Pipe in the text, and put the question in quotes:

Terminal window
echo 'Please refund my order.' |
thinkthen decide 'Does the customer request a refund?'

Output

true

true means yes: the message asks for a refund. If you see usage.key-missing instead, the key isn't set in this shell.

--check turns the answer into the exit code, so a script can branch on it. Here the answer is yes, so the script sends the message to the refunds queue:

Terminal window
message='Please refund my order.'
if echo "$message" |
thinkthen decide --check \
'Does the customer request a refund?' > /dev/null
then
echo 'send to the refunds queue'
else
status=$?
case "$status" in
1|3) ;;
*) exit "$status" ;;
esac
fi

Output

send to the refunds queue

In Windows PowerShell, $LASTEXITCODE holds the exit code:

Terminal window
'Please refund my order.' |
thinkthen decide --check `
'Does the customer request a refund?' > $null
if ($LASTEXITCODE -eq 0) {
'send to the refunds queue'
}

Output

send to the refunds queue