TL;DR
note月収化を目指すエンジニア向け自動投稿ツール設計。X API + スクレイピング + Claude APIで、トピック収集から投稿・エンゲージメント対応まで自動化し、手作業を50%削減します。実装難易度は中程度(Python基本+API連携知識で半日〜1日)。
背景:毎日3本の記事執筆は手動では破綻する
note で月収化を目指す場合、投稿頻度は「毎日1-3本」が一般的です。しかし以下の作業は全て手動になりがちです。
- 朝昼晩のトレンド・ネタ探索:合計90分
- 候補管理(どれ書いたか・どれ下書きか):不規則だが積み重なる
- コメント返し・スキ返し・フォロバ:1記事につき20分以上
これらをシステム化しないと、3本目で必ず力尽きます。本記事では、API 呼び出しと自動スクリプトを組み合わせた実装パターンを紹介します。
システム全体設計:5つの自動化レイヤー
[日次トピック自動収集]
↓
[YAML/JSONで一元管理]
↓
[下書き生成(Claude API)]
↓
[人手レビュー]
↓
[エンゲージメント自動巡回]
各段階で自動化できる部分と、人間判断が必要な部分を明確に分離します。
実装ステップ1:X API + Google検索でトピック自動収集
手順
X Search API(無料枠対応)と Google Custom Search API を並列実行し、毎朝 JSON にトピック候補を出力します。
import requests
import json
from datetime import datetime
# X API呼び出し
def fetch_x_topics(keywords: list) -> list:
headers = {"Authorization": f"Bearer {X_API_TOKEN}"}
topics = []
for kw in keywords:
url = "https://api.twitter.com/2/tweets/search/recent"
params = {
"query": f"{kw} -is:retweet",
"max_results": 30,
"tweet.fields": "public_metrics,created_at"
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
for tweet in response.json()["data"]:
topics.append({
"source": "x_trending",
"title": tweet["text"][:80],
"url": f"https://twitter.com/i/web/status/{tweet['id']}",
"engagement": tweet["public_metrics"]["like_count"],
"collected_at": datetime.now().isoformat()
})
return topics
# Google検索も並列実行
def fetch_google_topics(queries: list) -> list:
topics = []
for query in queries:
url = "https://www.googleapis.com/customsearch/v1"
params = {
"q": query,
"cx": GOOGLE_CX,
"key": GOOGLE_API_KEY,
"num": 10
}
response = requests.get(url, params=params)
if response.status_code == 200:
for item in response.json().get("items", []):
topics.append({
"source": "google_search",
"title": item["title"],
"url": item["link"],
"collected_at": datetime.now().isoformat()
})
return topics
# 毎朝実行(cron or systemd)
def daily_collect():
x_topics = fetch_x_topics(["Claude Code", "副業", "個人開発"])
google_topics = fetch_google_topics(["AI执筆ツール", "note月収化"])
all_topics = x_topics + google_topics
with open("topics.json", "w", encoding="utf-8") as f:
json.dump(all_topics, f, ensure_ascii=False, indent=2)
print(f"Collected {len(all_topics)} topics")
if __name__ == "__main__":
daily_collect()
ポイント
- X API は「最新トレンド」、Google は「SEO 需要」をカバーします
-
engagement
スコアでフィルタすることで、バズ記事を自動検出できます - JSON 出力により、後段のスクリプトで容易にパース可能です
実装ステップ2:YAML で記事ステータスを一元管理
トピック候補が溜まると、「どれ書いたか」「どれ下書き中か」が混乱します。YAML で状態遷移を管理すると、スクリプト側から自動進捗制御できます。
articles:
- id: article_001
title: Claude Codeで副業効率化する際の3つの罠
source: x_trending
status: draft # pending → draft → review → published
tone: business
target_words: 1500
created_at: 2026-05-16
published_at: null
- id: article_002
title: 自動投稿ツールで失敗する理由
source: google_search
status: published
tone: casual
published_at: 2026-05-15
Python で進捗を更新:
import yaml
def update_article_status(article_id: str, new_status: str):
with open("articles.yaml", "r", encoding="utf-8") as f:
data = yaml.safe_load(f)
for article in data["articles"]:
if article["id"] == article_id:
article["status"] = new_status
if new_status == "published":
article["published_at"] = datetime.now().isoformat()
break
with open("articles.yaml", "w", encoding="utf-8") as f:
yaml.dump(data, f, allow_unicode=True, default_flow_style=False)
実装ステップ3:下書き生成プロンプトの型化で出力ブレを抑える
Claude API で下書き生成する際、プロンプト型を固定化すると再現性が上がります。
from anthropic import Anthropic
def generate_draft(article_config: dict) -> str:
client = Anthropic()
system_prompt = """
あなたはnoteのエンジニア向け執筆者です。
読者層: 副業志望のエンジニア・個人開発者
禁止事項:
- 具体的な売上数値や根拠なき断言
- 過度なマーケティング表現
- 技術的に不正確な説明
必須構成:
1. 冒頭:実例またはペイン描写(150字)
2. 本論:3-4段落で深掘り(800字)
3. 終わり:示唆的なクロージング(100字)
トーン: 実務的・淡々と(説教的でない)
"""
user_prompt = f"""
タイトル: {article_config['title']}
トーン: {article_config['tone']}
参考URL: {article_config.get('reference_url', 'なし')}
ターゲット字数: {article_config.get('target_words', 1500)}字
上記を踏まえて下書きを生成してください。
"""
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=2000,
system=system_prompt,
messages=[
{"role": "user", "content": user_prompt}
]
)
return message.content[0].text
コツ
-
system_prompt
で「禁止・必須・トーン」を明記することで、AI の出力ブレが極めて小さくなります - 毎回プロンプト試行錯誤が不要になり、パラメータ(タイトル、トーン)を渡すだけで再現可能な下書き生成が実現します
実装ステップ4:人手レビューフロー(Discord連携)
自動投稿は禁止です。必ず人間が最終判断します。YAML で
status: reviewになった記事を、Discord 通知経由で人間に確認させるフロー。
import discord
async def notify_review_needed(article_id: str, draft_text: str):
webhook = discord.Webhook.from_url(DISCORD_WEBHOOK_URL, client=client)
embed = discord.Embed(
title=f"📝 記事レビュー待ち: {article_id}",
description=draft_text[:500] + "..." if len(draft_text) > 500 else draft_text,
color=discord.Color.blue()
)
embed.add_field(name="操作", value="✅OK / ❌NG でリアクション", inline=False)
await webhook.send(embed=embed)
ボスが Discord で
✅または
❌リアクションすると、自動で YAML を更新:
@client.event
async def on_reaction_add(reaction, user):
if user.bot:
return
if reaction.emoji == "✅":
# status → published に更新
update_article_status(article_id, "published")
elif reaction.emoji == "❌":
# status → draft に戻す
update_article_status(article_id, "draft")
実装ステップ5:エンゲージメント自動巡回
記事投稿後、コメント返し・スキ返し・フォローバックを自動化します。
def auto_engagement_loop():
# note API で過去24時間の自分の投稿を取得
my_articles = fetch_my_recent_articles(hours=24)
for article in my_articles:
# コメント取得
comments = fetch_comments(article["id"])
for comment in comments:
# 未返信ならスキ返し + テンプレ返信
if not is_replied(comment["id"]):
like_comment(comment["id"])
reply_text = generate_reply_template(comment["text"])
post_reply(article["id"], comment["id"], reply_text)
# 新規フォロワーに自動フォロバ
new_followers = fetch_new_followers(hours=24)
for follower in new_followers:
if not is_following(follower["id"]):
follow_user(follower["id"])
# 毎日定時実行
schedule.every().day.at("09:00").do(auto_engagement_loop)
つまづきポイント
- API レート制限: note の API は時間ごとのリクエスト制限があります。バッチ処理時は遅延を入れてください。
- スキ返し の過度な自動化: 人力感を失うとフォロワーに違和感を持たれます。「いいね返し」は自動でも、コメント返しは軽く人手チェックをお勧めします。
-
プロンプト漂流: Claude API を呼び出すたびに、同じ
system_prompt
を使用してください。異なるプロンプトを使うと、記事の品質が統一されません。
まとめ
note での月収化は「毎日書く」から「仕組み化して書く」に切り替えた時点で大きく有利になります。本記事で紹介した5つのステップを実装することで:
- トピック探索:朝の90分 → ほぼ0分(朝チェック5分のみ)
- 記事管理:スプレッドシート作業 → スクリプト自動化
- エンゲージメント対応:フォロバ・スキ返し手動 → ほぼ自動
結果として、「書く」という本質的な作業に集中でき、月3-4本の投稿を継続できるようになります。
さらに詳しい実装手順はnoteで公開中
この記事では概要のみ紹介しました。実装の完全手順・プロンプト全文・運用ノウハウ、および X API の設定・note API の認証フローについては、以下のnoteで詳しく解説しています。