Recipes
Tell yourself when a job finishes
long-job && sock send "long-job passed" || sock send "long-job failed"
Pipe output
make test 2>&1 | tail -20 | sock send
Text arrives as Markdown, so fence logs:
{ echo '```'; make test 2>&1 | tail -20; echo '```'; } | sock send
Cron
0 6 * * * SOCK_TOKEN=sock_pt_... /usr/local/bin/sock send "backup ran at $(date)"
Keep the token in a file readable only by the job, not in a global shell profile.
Reply handlers
Run a script for every message you send back:
sock listen --exec ./on-reply.sh
#!/bin/sh
# stdin is the message as JSON; the id is in the environment
jq -r .text | tee -a replies.log
sock send "got it ($SOCK_MESSAGE_ID)"
Exit 0 acks the message. Delivery is at-least-once, so key side effects on SOCK_MESSAGE_ID.
Safe retries from your own code
Pass a stable key so a rerun never posts twice:
sock send --idempotency-key "deploy-$GIT_SHA" "deployed $GIT_SHA"
Keys are 1 to 128 of A-Z a-z 0-9 . _ : -, starting with a letter or digit, and hold for 24 hours.