Automating Incident Reporting with
JavaScript & Google APIs

Here's how to break a manual process that may take up to 2hr to do, and transform it into an automated process done in 2 min with the click of a button.

Overview

Managing daily incident reports was a time-consuming and error-prone process for my team. We needed an automated way to collect incident data, generate insightful reports, and streamline communication across teams. To solve this, I developed a JavaScript-based automation script that integrates Google Sheets, Google Slides, and Gemini AI to efficiently generate a structured incident report.

Challenges

  • Manual Data Processing: The team manually collected and compiled incident data from Google Sheets, leading to inconsistencies and delays.
  • Lack of Standardized Titles: Incident summaries varied in structure, making it difficult to quickly identify key issues.
  • Report Generation Bottlenecks: Creating presentation slides for daily reports was tedious and repetitive.

Solution

I developed a JavaScript-based automation script that:

  • Extracts data from a Google Sheets spreadsheet containing daily incidents.
  • Filters incidents based on key attributes like impact level, market, and resolution status.
  • Generates AI-powered titles using the Google's Gemini API to standardize and condense incident descriptions.
  • Creates an automated Google Slides presentation, organizing incidents by market and impact level for easy review.
This solution automates data collection, formatting, and presentation creation.

Technical Breakdown

1. Fetching Data from Google Sheets

Using Google Apps Script, the script connects to a predefined Google Sheets file and extracts relevant incident data:

const SPREADSHEET_ID = "your-sheet-id";
const SHEET_NAME = "General";
const spreadsheet = SpreadsheetApp.openById(SPREADSHEET_ID);
const sheet = spreadsheet.getSheetByName(SHEET_NAME);

2. Processing and Filtering Data

The script processes the raw data, filters relevant incidents, and prepares it for presentation:

function processIncidents(rawData) {
    return rawData
        .filter(incident => incident.status === 'active')
        .map(incident => ({
            title: incident.description,
            impact: incident.impactLevel,
            market: incident.region,
            resolution: incident.solution
        }));
}
                            

3. AI Title Generation

Integration with Gemini AI to generate standardized incident titles:

async function generateTitle(description) {
    const prompt = `Summarize this incident: ${description}`;
    const result = await gemini.generateText(prompt);
    return result.trim();
}
                            

4. Creating Presentation Slides

Finally, the script generates a structured presentation using the Google Slides API:

function createSlides(processedData) {
    const presentation = SlidesApp.create('Daily Incident Report');
    processedData.forEach(incident => {
        const slide = presentation.appendSlide();
        addContentToSlide(slide, incident);
    });
    return presentation.getUrl();
}
                            

Results & Impact

  • Time Efficiency: Report generation now takes seconds instead of hours.
  • Standardized Reporting: AI-generated titles improved consistency and readability.
  • Scalability: The script can be easily adapted to different teams or reporting needs.

Lessons Learned & Next Steps

  • Key Learnings
    • Importance of user feedback in automation design
    • Value of modular code structure for maintainability
    • Benefits of iterative development approach
  • Future Improvements
    • Add custom template creation functionality
    • Implement real-time collaboration features
    • Enhance AI-powered analytics capabilities

Conclusion

This project demonstrates how automation can significantly improve operational efficiency and data accuracy. By combining Google Workspace APIs with AI capabilities, we created a solution that not only saves time but also enhances the quality of incident reporting and analysis.

Is this a possible use scenario to you or your team? Let's talk about it.

Get in Touch