Bash · Techniques
Handle not sure
refund_code=$? names the exit code of decide. case reads its three values: 0 for yes, 1 for no, and 3 for not sure.
The refund goes to refunds and the thanks gets a reply. The send-back line lands in the band 0.2:0.8 and goes to a person.
question="Does the customer ask for a refund?"
cat <<'EOF' |
Please refund my order. It arrived broken.
Thanks for the quick help yesterday!
I want to send this back.
EOF
while read -r message; do
printf '%s' "$message" |
thinkthen decide "$question" \
--quiet \
--threshold 0.2:0.8
refund_code=$?
case $refund_code in
0) echo "refund: $message" ;;
1) echo "reply: $message" ;;
3) echo "a person: $message" ;;
esac
doneOutput
refund: Please refund my order. It arrived broken. reply: Thanks for the quick help yesterday! a person: I want to send this back.
exit 0
On GitHub: github.com/botassembly/thinkthen