Monitor the Internet for Specific Topics

October 19, 2024

One of the most powerful features of Tasking.agency is the ability to trigger your agents programmatically using the API. This allows you to set up automated monitoring, scheduled research, and custom workflows that run without any manual intervention.

In this tutorial, we'll show you how to set up scheduled tasks that trigger your agents to monitor the internet for specific topics using cron jobs on macOS/Linux or Task Scheduler on Windows.

Understanding the Agent Chat API

The Tasking.agency Workspace exposes a local API at http://0.0.0.0:3021 that allows you to send messages to your agents. First, you need to find your agent's ID:

bash
# List all available agents
curl http://0.0.0.0:3021/api/agents | jq '.data[] | {id, alias, motivation}'

# Example output:
# {
#   "id": "cBkW8qQhx1cg2eoWajjn",
#   "alias": "Samantha",
#   "motivation": "Research and analysis specialist"
# }
Finding your agent ID
bash
# Simple chat (for one-off monitoring requests)
curl -X POST http://0.0.0.0:3021/api/agents/YOUR_AGENT_ID/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "message": "Search for and summarize the latest news about AI developments from the past 24 hours"
  }'
Basic API call for quick monitoring

Setting Up Scheduled Tasks

Choose your platform below to see how to create a monitoring script and schedule it to run automatically:

bash
#!/bin/bash
# monitor-agent.sh

AGENT_ID="your-agent-id-here"
API_URL="http://0.0.0.0:3021/api/agents/${AGENT_ID}/chat"
MESSAGE="Research and summarize the latest news about quantum computing from the past 24 hours"

curl -X POST "${API_URL}" \
  -H 'Content-Type: application/json' \
  -d "{
    \"message\": \"${MESSAGE}\"
  }"
Create the monitoring script for your platform
bash
# Make the script executable
chmod +x monitor-agent.sh

# Add to crontab (crontab -e)

# Run every day at 9:00 AM
0 9 * * * /path/to/monitor-agent.sh

# Run every hour
0 * * * * /path/to/monitor-agent.sh

# Run every 15 minutes
*/15 * * * * /path/to/monitor-agent.sh
Schedule the script to run automatically

Advanced: Monitoring Multiple Topics

You can customize your monitoring script to track multiple topics in a single run:

bash
#!/bin/bash
# advanced-monitor.sh

AGENT_ID="your-agent-id-here"
API_URL="http://0.0.0.0:3021/api/agents/${AGENT_ID}/chat"

# Monitor multiple topics
TOPICS=("artificial intelligence" "quantum computing" "renewable energy")

for TOPIC in "${TOPICS[@]}"; do
  MESSAGE="Search for and summarize the latest developments in ${TOPIC} from the past 24 hours"

  echo "Monitoring: ${TOPIC}..."
  curl -X POST "${API_URL}" \
    -H 'Content-Type: application/json' \
    -d "{
      \"message\": \"${MESSAGE}\"
    }"

  # Wait between requests to avoid overwhelming the agent
  sleep 5
done
Monitor multiple topics in one script

Using Chatter Context for Persistent Conversations

For ongoing monitoring projects where you need conversation history and task context, you can use chatter-based chat. First, get your agent's tasks and chatters:

bash
# 1. Get your agent's tasks and their chatters
curl http://0.0.0.0:3021/api/agents/YOUR_AGENT_ID/tasks | jq '.data[] | {taskId, title, chatters}'

# 2. Use a chatter ID for context-aware monitoring
CHATTER_ID="your-chatter-id-here"
curl -X POST http://0.0.0.0:3021/api/agents/YOUR_AGENT_ID/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "message": "Check for updates on quantum computing since our last discussion",
    "chatterId": "'$CHATTER_ID'"
  }'
Chat with task context - messages are saved to the chatter discussion

Next Steps

Now that you have automated monitoring set up, you can:

• Use chatter context for ongoing research projects with conversation history

• Configure your agent to analyze trends over time

• Set up different monitoring schedules for different topics

• Combine multiple agents for specialized research tasks

• Export results to email or notification systems