I have reviewed the Letta Switchboard API documentation. It provides a straightforward interface for scheduling one-time and recurring messages for Letta agents.
To facilitate easy setup and usage, I have prepared the following Bash script. It wraps the curl commands into convenient functions.
Usage
- Save the script as
switchboard.sh. - Make it executable:
chmod +x switchboard.sh. - Set your API key:
export LETTA_API_KEY="your_key_here". - Run commands:
./switchboard.sh once <agent_id> <message> <timestamp>./switchboard.sh cron <agent_id> <message> <cron_expression>./switchboard.sh list
The Script
#!/bin/bash
# Letta Switchboard Wrapper
API_BASE="https://letta--switchboard-api.modal.run"
if [ -z "$LETTA_API_KEY" ]; then
echo "Error: LETTA_API_KEY is not set."
echo "Export it with: export LETTA_API_KEY='your_key'"
exit 1
fi
cmd="$1"
shift
case "$cmd" in
once)
if [ "$#" -ne 3 ]; then echo "Usage: $0 once <agent_id> <message> <iso_timestamp>"; exit 1; fi
# Using jq to safely construct JSON
curl -X POST "$API_BASE/schedules/one-time" \
-H "Authorization: Bearer $LETTA_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg aid "$1" --arg msg "$2" --arg at "$3" '{agent_id: $aid, message: $msg, execute_at: $at}')"
;;
cron)
if [ "$#" -ne 3 ]; then echo "Usage: $0 cron <agent_id> <message> <cron_expression>"; exit 1; fi
curl -X POST "$API_BASE/schedules/recurring" \
-H "Authorization: Bearer $LETTA_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg aid "$1" --arg msg "$2" --arg cron "$3" '{agent_id: $aid, message: $msg, cron: $cron}')"
;;
list)
echo "--- One-time Schedules ---"
curl -s -H "Authorization: Bearer $LETTA_API_KEY" "$API_BASE/schedules/one-time" | jq .
echo -e "\n--- Recurring Schedules ---"
curl -s -H "Authorization: Bearer $LETTA_API_KEY" "$API_BASE/schedules/recurring" | jq .
;;
*)
echo "Usage: $0 {once|cron|list} ..."
echo " once: <agent_id> <message> <iso_timestamp>"
echo " cron: <agent_id> <message> <cron_expression>"
echo " list: View all schedules"
exit 1
;;
esac
Note: This script requires jq to be installed on your system for safe JSON handling.