Stop wasting hours in status meetings and manually compiling progress reports. Your company's objectives and key results (OKRs) are too important for tedious, error-prone manual tracking. In a world of automation and APIs, your goal management should be as dynamic and intelligent as the rest of your tech stack.
What if an automated agent could monitor your team's progress, identify at-risk goals, and deliver a concise summary to your stakeholders on a schedule? With Goals.do, this isn't a futuristic dream; it's a simple script away. By treating your goals as code, you unlock the ability to build powerful, custom automations.
This post will guide you through creating an intelligent agent that connects to the Goals.do API, analyzes your OKR progress, and reports its findings automatically. Let's transform your strategy from a static document into an executable, self-monitoring system.
Let's be honest: the traditional OKR process is often broken. It usually involves:
This manual toil drains productivity and makes goal management a chore rather than a motivator.
Goals.do changes the paradigm. Instead of trapping your strategy in a UI, we expose it through a clean, simple API. This "Business-as-Code" approach means your objectives are:
This is the foundation for building our intelligent agent. Your goals are no longer just text on a screen; they are structured data ready to be analyzed and acted upon.
We'll build a Node.js agent that performs a few key functions. You can adapt this pattern to any language or environment.
First, let's set up our project and write the code to fetch our OKRs.
# Create a new directory and initialize a Node.js project
mkdir goal-agent
cd goal-agent
npm init -y
# Install the Goals.do SDK and an HTTP client for Slack
npm install goals.do axios
Now, create a file named agent.js. We'll start by initializing the SDK and fetching the objectives owned by our product team.
// agent.js
import { Goals } from 'goals.do';
import axios from 'axios';
// Best practice: Store secrets in environment variables
const GOALS_API_KEY = process.env.GOALS_API_KEY;
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL;
const TEAM_IDENTIFIER = 'product-team@example.com';
// Initialize the SDK
Goals.init({ apiKey: GOALS_API_KEY });
async function fetchTeamObjectives() {
console.log(`Fetching objectives for owner: ${TEAM_IDENTIFIER}...`);
try {
const objectives = await Goals.list({ owner: TEAM_IDENTIFIER, timeframe: 'Q4 2024' });
console.log(`Found ${objectives.length} objectives.`);
return objectives;
} catch (error) {
console.error("Failed to fetch objectives:", error);
return [];
}
}
// We'll call our main function later
// fetchTeamObjectives();
Next, let's add the "intelligent" part. We’ll create a function that takes an objective, calculates its progress, and assigns a status. Our logic will be simple: if any KR is less than 50% complete, we'll flag the parent objective as "Needs Attention".
// Add this function to agent.js
function analyzeObjectiveProgress(objective) {
let totalKRs = objective.keyResults.length;
if (totalKRs === 0) {
return { title: objective.title, progress: 0, status: 'No KRs' };
}
let cumulativeProgress = 0;
let atRiskKRs = [];
for (const kr of objective.keyResults) {
// Avoid division by zero
const progress = kr.target > 0 ? (kr.current / kr.target) * 100 : 100;
cumulativeProgress += progress;
// Our simple "at-risk" logic
if (progress < 50) {
atRiskKRs.push(kr.description);
}
}
const overallProgress = cumulativeProgress / totalKRs;
const status = atRiskKRs.length > 0 ? 'Needs Attention' : 'On Track';
return {
title: objective.title,
progress: overallProgress.toFixed(1),
status,
atRiskKRs
};
}
With our analysis logic in place, the final step is to format a clear message and send it to Slack.
// Add these functions to agent.js
function generateReport(analysisResults) {
let message = `*🚀 Weekly OKR Check-in for ${TEAM_IDENTIFIER} 🚀*\n\n`;
if (analysisResults.length === 0) {
return message + "_No objectives found for the current timeframe._";
}
analysisResults.forEach(res => {
const icon = res.status === 'On Track' ? '✅' : '⚠️';
message += `*${icon} ${res.title}* - ${res.progress}% Complete (${res.status})\n`;
if (res.atRiskKRs.length > 0) {
message += `> _KRs needing focus: ${res.atRiskKRs.join(', ')}_\n`;
}
});
return message;
}
async function sendSlackNotification(message) {
if (!SLACK_WEBHOOK_URL) {
console.log("SLACK_WEBHOOK_URL not set. Printing report to console:");
console.log(message);
return;
}
try {
await axios.post(SLACK_WEBHOOK_URL, { text: message });
console.log("Successfully sent report to Slack!");
} catch (error) {
console.error("Failed to send Slack notification:", error);
}
}
// The main function to tie it all together
async function run() {
const objectives = await fetchTeamObjectives();
const analysisResults = objectives.map(analyzeObjectiveProgress);
const reportMessage = generateReport(analysisResults);
await sendSlackNotification(reportMessage);
}
// Run the agent
run();
To run your agent, set your environment variables and execute the script:
export GOALS_API_KEY='your_api_key_here'
export SLACK_WEBHOOK_URL='your_slack_webhook_url_here'
node agent.js
You'll get a beautiful, automated summary right in your team's Slack channel!
<!-- Placeholder for a conceptual image -->This is just the beginning. The power of the "Goals as Code" approach is its extensibility. Here are a few ideas to make your agent even smarter:
By leveraging the Goals.do API, you've done more than automate a report. You've created an active, intelligent system that makes your company strategy a living part of your daily operations. You've saved your team from mind-numbing manual work and provided stakeholders with real-time, actionable insights.
This is the future of goal management. It's time to stop just tracking your goals and start putting them to work.
Ready to build your own goal-driven automations? Explore the Goals.do API documentation or sign up for free today and turn your strategy into code.