Droid
Email checker with Droid CLI. Verify emails in Droid AI assistant.
Droidは開発者向けのAI搭載ターミナルアシスタントです。Droidワークフローでメール検証にEmailVerifyを統合する方法を学びます。
Droidとは?
Droidは以下を提供するモダンなAIターミナルアシスタントです:
- インテリジェントなコマンド提案
- コード生成と説明
- シェル自動化
- マルチモデル対応(GPT-4、Claude、ローカルモデル)
セットアップ
EmailVerify CLIのインストール
npm install -g @emailverify/cli
bv config set api-key YOUR_API_KEY環境設定
export EMAILVERIFY_API_KEY=your-api-keyDroidでの使用
クイック検証
あなた: emailverifyでjohn@example.comを検証
Droid:
Running: bv verify john@example.com --json
{
"email": "john@example.com",
"status": "valid",
"score": 0.88,
"result": {
"deliverable": true,
"disposable": false,
"role": false
}
}
Email is valid (88% confidence)バッチ操作
あなた: contacts.csvのすべてのメールを検証してレポートを作成
Droid:
I'll process the CSV and verify each email.
Reading contacts.csv... 250 entries found.
Progress: ████████████████████ 100%
Summary Report:
┌──────────────┬───────┬────────┐
│ Status │ Count │ % │
├──────────────┼───────┼────────┤
│ Valid │ 198 │ 79.2% │
│ Invalid │ 32 │ 12.8% │
│ Unknown │ 12 │ 4.8% │
│ Disposable │ 8 │ 3.2% │
└──────────────┴───────┴────────┘
Generated files:
- contacts_valid.csv (198 emails)
- contacts_invalid.csv (32 emails)
- contacts_review.csv (20 emails)
Would you like me to explain any of the invalid emails?コード生成
あなた: メール検証用のNode.js APIエンドポイントを作成
Droid:
// routes/verify.ts
import { Router } from 'express';
import rateLimit from 'express-rate-limit';
const router = Router();
// Rate limit: 100 requests per minute
const limiter = rateLimit({
windowMs: 60 * 1000,
max: 100,
message: { error: 'Too many requests' }
});
router.post('/verify', limiter, async (req, res) => {
const { email } = req.body;
if (!email) {
return res.status(400).json({ error: 'Email is required' });
}
try {
const response = await fetch('https://api.emailverify.ai/v1/verify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.EMAILVERIFY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email }),
});
const result = await response.json();
return res.json({
email,
isValid: result.status === 'valid',
score: result.score,
flags: {
disposable: result.result.disposable,
role: result.result.role,
}
});
} catch (error) {
return res.status(500).json({ error: 'Verification service unavailable' });
}
});
export default router;Saved to routes/verify.ts
シェル自動化
あなた: 毎日新規登録を検証するcronジョブを作成
Droid:
# Create the verification script
cat > /usr/local/bin/verify-daily-signups.sh << 'EOF'
#!/bin/bash
set -e
LOG_FILE="/var/log/email-verification.log"
DB_HOST="${DB_HOST:-localhost}"
DB_NAME="${DB_NAME:-myapp}"
echo "$(date): Starting daily email verification" >> $LOG_FILE
# Get unverified emails from database
emails=$(psql -h $DB_HOST -d $DB_NAME -t -c \
"SELECT email FROM users WHERE email_verified IS NULL AND created_at > NOW() - INTERVAL '1 day'")
count=0
invalid=0
for email in $emails; do
result=$(bv verify "$email" --json 2>/dev/null)
status=$(echo "$result" | jq -r '.status')
if [ "$status" = "valid" ]; then
psql -h $DB_HOST -d $DB_NAME -c \
"UPDATE users SET email_verified = true WHERE email = '$email'"
else
psql -h $DB_HOST -d $DB_NAME -c \
"UPDATE users SET email_verified = false, email_status = '$status' WHERE email = '$email'"
((invalid++))
fi
((count++))
sleep 0.1 # Rate limiting
done
echo "$(date): Verified $count emails, $invalid invalid" >> $LOG_FILE
EOF
chmod +x /usr/local/bin/verify-daily-signups.sh
# Add to crontab (runs at 2 AM daily)
(crontab -l 2>/dev/null; echo "0 2 * * * /usr/local/bin/verify-daily-signups.sh") | crontab -
echo "Cron job created. Will run daily at 2 AM."統合テスト
あなた: メール検証の統合テストを書いて
Droid:
// __tests__/email-verification.test.ts
import { describe, it, expect, beforeAll } from 'vitest';
describe('Email Verification Integration', () => {
const API_URL = 'https://api.emailverify.ai/v1/verify';
let apiKey: string;
beforeAll(() => {
apiKey = process.env.EMAILVERIFY_API_KEY!;
if (!apiKey) {
throw new Error('EMAILVERIFY_API_KEY not set');
}
});
async function verifyEmail(email: string) {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email }),
});
return response.json();
}
it('returns valid for known good email', async () => {
const result = await verifyEmail('test@gmail.com');
expect(result.status).toBe('valid');
expect(result.score).toBeGreaterThan(0.5);
});
it('detects disposable emails', async () => {
const result = await verifyEmail('test@mailinator.com');
expect(result.result.disposable).toBe(true);
});
it('detects role-based emails', async () => {
const result = await verifyEmail('info@example.com');
expect(result.result.role).toBe(true);
});
it('handles invalid domains', async () => {
const result = await verifyEmail('user@thisisnotarealdomain12345.xyz');
expect(result.status).toBe('invalid');
});
it('returns proper structure', async () => {
const result = await verifyEmail('user@example.com');
expect(result).toHaveProperty('email');
expect(result).toHaveProperty('status');
expect(result).toHaveProperty('score');
expect(result).toHaveProperty('result');
expect(result.result).toHaveProperty('deliverable');
expect(result.result).toHaveProperty('disposable');
expect(result.result).toHaveProperty('role');
});
});Droidエイリアス
Droid設定にこれらを追加:
# ~/.droid/aliases.yml
aliases:
vmail:
description: "Verify an email address"
command: "bv verify $1 --color"
vmail-json:
description: "Verify an email and output JSON"
command: "bv verify $1 --json | jq ."
vmail-batch:
description: "Verify emails from a file"
command: "bv verify --file $1 --output results.csv"
vmail-check:
description: "Quick check if email is valid (returns 0 or 1)"
command: "bv verify $1 --quiet"使用方法:
droid vmail user@example.com
droid vmail-batch contacts.txt