Skip to content
Documentation
Command

/start-10-2

Lesson command

From plugin
ai-agent-camp
345200 skills8 agents200 commands
Install
$ npx -y skills add minicoohei/ai-agent-camp --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/start-10-2

Context preview

What this command does when you run it.

Lesson command

Command definition

start-10-2.md
description: "Lesson command"
chapter: "courses/aiagent/lesson03-core/module10-gas"
prerequisites: ["start-10-1"]
duration: "約30分"
level: "intermediate"
tags: ["gas", "calendar", "google", "automation"]
nonInteractiveMode: deferred

🎓 Lesson 10-2: Google Calendar API連携・イベント自動化

📍 このセッションでやること

**Lesson 10-2: GASとGoogle Calendar連携** へようこそ!

| 項目 | 内容 | |------|------| | ゴール | GASからGoogle Calendar APIでイベント操作を自動化する | | 所要時間 | 約30分 | | 使うスキル | gas-clasp-ops, Google Calendar API, gogcli | | 前提条件 | Lesson 10-1 完了、GASプロジェクト作成済み、Apps Script API 有効化済み | | 教材ページ | [Module 10: GAS](https://ai-agent.camp/ja/course/module-10) を並行参照 |

**このセッションの流れ:** 1. カレンダー取得スクリプトの作成 2. イベントの作成・更新・削除 3. トリガーと通知の設定

セッション終了時には、カレンダー連携の自動化ができるようになっています。

> **💡 ヒント**: AIの応答が途中で止まった場合は「続きを表示して」「止まってるよ」と入力すると再開します。これはCursorの仕様で、故障ではありません。

---

🎯 準備チェック

まずは準備が整っているか確認しましょう。

**AskQuestionの設定:**

{
  "title": "🎯 セッション開始前の確認",
  "questions": [{
    "id": "readiness",
    "prompt": "準備はできていますか?",
    "options": [
      {"id": "ready", "label": "準備OK!始めましょう"},
      {"id": "check_prereq", "label": "前提条件を確認したい"},
      {"id": "view_html", "label": "先に教材ページを見たい"},
      {"id": "different_lesson", "label": "別のレッスンに移動したい"}
    ]
  }]
}

(ready → Step 1へ) (check_prereq → 前提条件の確認を実行) (view_html → 教材ページのパスを案内) (different_lesson → モジュール一覧を表示)

---

🚀 Step 1: カレンダー取得スクリプト

**前提条件チェック(自動実行):** 以下を確認してから進めてください:

1. **`.clasp.json` の存在確認**: `gas-example/.clasp.json` が存在するか確認。存在しない場合は 4-1 を先に完了してください。 2. **Apps Script API の有効化確認**: https://script.google.com/home/usersettings で「Google Apps Script API」が ON になっているか確認。 3. **`appsscript.json` の oauthScopes 設定**: Calendar API を使うため、`gas-example/appsscript.json` に以下のスコープを追加してください:

{
  "timeZone": "Asia/Tokyo",
  "dependencies": {},
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "oauthScopes": [
    "https://www.googleapis.com/auth/calendar",
    "https://www.googleapis.com/auth/script.external_request"
  ]
}

> **重要**: oauthScopes を設定しないと、Calendar API の呼び出し時に「Permission denied」エラーが発生します。

AskUserQuestion(AskQuestion)で「このまま進める / 例だけ確認 / スキップ」を選べます。

**AskQuestionの設定例:**

{
  "title": "🚀 Step 1: カレンダー取得スクリプト",
  "questions": [{
    "id": "step_action",
    "prompt": "このステップをどうしますか?",
    "options": [
      {"id": "practice", "label": "このまま進める"},
      {"id": "review", "label": "例だけ確認する"},
      {"id": "skip", "label": "スキップする"}
    ]
  }]
}

**選択後の案内(例)**: 入力内容:

gas-example ディレクトリに Calendar.gs ファイルを作成し、以下の内容を記述してください:

function getDefaultCalendar() {
  const calendar = CalendarApp.getDefaultCalendar();
  Logger.log("カレンダー名: " + calendar.getName());
  Logger.log("カレンダーID: " + calendar.getId());
  return calendar;
}

function getAllCalendars() {
  const calendars = CalendarApp.getAllCalendars();
  Logger.log("全カレンダー数: " + calendars.length);
  calendars.forEach(calendar => {
    Logger.log("- " + calendar.getName());
  });
  return calendars;
}

clasp push で同期してください。

**期待される結果**: Calendar.gs がGoogleドライブに同期され、カレンダー一覧を取得できます。

---

🚀 Step 2: イベント作成機能

AskUserQuestion(AskQuestion)で「このまま進める / 例だけ確認 / スキップ」を選べます。

**AskQuestionの設定例:**

{
  "title": "🚀 Step 2: イベント作成機能",
  "questions": [{
    "id": "step_action",
    "prompt": "このステップをどうしますか?",
    "options": [
      {"id": "practice", "label": "このまま進める"},
      {"id": "review", "label": "例だけ確認する"},
      {"id": "skip", "label": "スキップする"}
    ]
  }]
}

**選択後の案内(例)**: 入力内容:

Calendar.gs に以下のイベント作成関数を追加してください:

function createSimpleEvent(title, startTime, endTime) {
  const calendar = CalendarApp.getDefaultCalendar();
  const event = calendar.createEvent(title, startTime, endTime);
  Logger.log("イベント作成: " + title);
  Logger.log("イベントID: " + event.getId());
  return event.getId();
}

function createTomorrowEvent() {
  const tomorrow = new Date();
  tomorrow.setDate(tomorrow.getDate() + 1);

  const startTime = new Date(tomorrow.getFullYear(), tomorrow.getMonth(), tomorrow.getDate(), 14, 0, 0);
  const endTime = new Date(startTime.getTime() + 60 * 60 * 1000);

  return createSimpleEvent("テストイベント", startTime, endTime);
}

clasp push して、GASエディタで createTomorrowEvent を実行してください。

**期待される結果**: 明日14:00から1時間の「テストイベント」がカレンダーに追加されます。

---

🚀 Step 3: イベント一覧取得

AskUserQuestion(AskQuestion)で「このまま進める / 例だけ確認 / スキップ」を選べます。

**AskQuestionの設定例:**

{
  "title": "🚀 Step 3: イベント一覧取得",
  "questions": [{
    "id": "step_action",
    "prompt": "このステップをどうしますか?",
    "options": [
      {"id": "practice", "label": "このまま進める"},
      {"id": "review", "label": "例だけ確認する"},
      {"id": "skip", "label": "スキップする"}
    ]
  }]
}

**選択後の案内(例)**: 入力内容:

Calendar.gs に以下のイベント取得関数を追加してください:

function getTodayEvents() {
  const calendar = CalendarApp.getDefaultCalendar();
  const today = new Date();
  const dayStart = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
  const dayEnd = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);

  const events = calendar.getEvents(dayStart, dayEnd);
  Logger.log("今日のイベント数: " + events.length);

  events.forEach(event => {
    Logger.log("- " + event.getTitle() + " (" + event.getStartTime().toLocaleString() + ")");
  });

  return events;
}

clasp push して実行してください。

**期待される結果**: 今日のカレンダーイベント一覧がログに表示されます。

---

🚀 Step 4: 定期実行トリガー設定

AskUserQuestion(AskQuestion)で「このまま進める / 例だけ確認 / スキップ」を選べます。

**AskQuestionの設定例:**

{
  "title": "🚀 Step 4: 定期実行トリガー設定",
  "questions": [{
    "id": "step_action",
    "prompt": "このステップをどうしますか?",
    "options": [
      {"id": "practice", "label": "このまま進める"},
      {"id": "review", "label": "例だけ確認する"},
      {"id": "skip", "label": "スキップする"}
    ]
  }]
}

**選択後の案内(例)**: 入力内容:

Calendar.gs に以下のトリガー設定関数を追加してください:

function dailyMorningTask() {
  const events = getTodayEvents();
  Logger.log("本日のイベント確認: " + events.length + "件");
  // ここにメール通知などの処理を追加
}

function createDailyTrigger() {
  // 既存トリガーを削除
  const triggers = ScriptApp.getProje
Read more
Ships withai-agent-camp

AI Agent Training for Non-Engineers - Complete Guide to Claude Code / Cursor / Codex ### ⚠️ Before you clone Official repository (maintained by the authors): Running AI agents from this repo grants them shell, file-write, and external-API permissions on your

Get the whole plugin