Every time a developer pushes code to AiSalonHub, a marketing campaign begins — automatically. Sitemaps regenerate, SEO audits run, social cards update, and content freshness scores recalculate. There is no manual handoff, no Slack ping, no Jira ticket. The deployment itself is the trigger.
This post breaks down how AiSalonHub uses Cloudflare Workers, D1 database triggers, and Telegram webhooks to wire the deploy pipeline directly into the marketing distribution engine.
The Problem — Content and Deployment Teams Operate in Silos
In most organizations, engineering ships code to production and marketing finds out hours or days later. The result is predictable friction:
| Issue | Engineering Side | Marketing Side |
|---|---|---|
| New features | Deployed and live | Unaware the change happened |
| SEO metadata | Not in deploy checklist | Must manually audit post-deploy |
| Content updates | Requires PR + deploy | Must request through dev queue |
| Social distribution | Not in scope | Manual sharing |
| Sitemap freshness | Regenerated on deploy? Maybe | Must verify independently |
Before AiSalonHub's feedback loop, a typical rollout looked like: developer merges PR and deploys; three days later marketing notices new functionality exists; someone writes a quick social post from memory; the sitemap stays stale for a week. The gap between deploy and distribution cost weeks of organic traffic.
The Solution — Automated Feedback Loop Connecting Deploy Events to Marketing Actions
The feedback loop treats every deployment as a structured event flowing through a pipeline of automated marketing actions. The principle: **deploy once, distribute everywhere.**
The core loop has four stages:
1. **Deploy Event** — Code merges to main, CI/CD builds and deploys to Cloudflare Workers.
2. **Webhook Dispatch** — The deploy pipeline fires a webhook to a dedicated Worker endpoint.
3. **Action Pipeline** — The Worker parses the event type and executes marketing actions.
4. **Notification & Logging** — Results push to Telegram, the EmDash CMS dashboard, and an audit log in D1.
Architecture — Workers Webhooks, D1 Triggers, Telegram Notifications
1. Deploy Webhook Receiver
A Worker at `hooks.aisalonhub.com/deploy` listens for POST requests from GitHub Actions. The payload carries deployment metadata: `commit_hash`, `branch`, `changed_files[]`, and `deploy_type`.
2. Action Router (Workers + D1)
The receiver queries D1 for the appropriate action chain. Each deploy type maps to a sequence stored in the `deploy_actions` table:
```sql
CREATE TABLE deploy_actions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
deploy_type TEXT NOT NULL,
action_name TEXT NOT NULL,
action_endpoint TEXT NOT NULL,
priority INTEGER DEFAULT 0,
enabled INTEGER DEFAULT 1
);
INSERT INTO deploy_actions (deploy_type, action_name, action_endpoint, priority) VALUES
('full', 'regenerate_sitemap', '/actions/sitemap', 1),
('full', 'run_seo_audit', '/actions/seo-audit', 2),
('full', 'refresh_comparison_cache', '/actions/refresh-comparisons', 3),
('full', 'update_social_cards', '/actions/social-cards', 4),
('content-only', 'regenerate_sitemap', '/actions/sitemap', 1),
('content-only', 'bump_freshness_scores', '/actions/freshness', 2);
```
3. Telegram Notification Bot
Every action sends a status update to a Telegram channel: ✅ or ❌ per action, execution time, and links to updated pages.
4. EmDash CMS Plugin Integration
The CMS plugin system lets marketing configure — without code — which actions fire on which deploy types. Developers own the Workers and D1 infrastructure; marketing owns the action configuration.
Implementation — Key Code Snippets
Deploy Webhook Handler
```javascript
export default {
async fetch(request, env) {
if (request.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });
}
const payload = await request.json();
const { commit_hash, branch, changed_files, deploy_type } = payload;
const signature = request.headers.get('X-Deploy-Signature');
if (!verifySignature(signature, payload, env.WEBHOOK_SECRET)) {
return new Response('Unauthorized', { status: 401 });
}
const actions = await env.DB.prepare(
'SELECT * FROM deploy_actions WHERE deploy_type = ? AND enabled = 1 ORDER BY priority'
).bind(deploy_type).all();
const results = [];
for (const action of actions.results) {
try {
const start = Date.now();
const response = await executeAction(action, payload, env);
results.push({
action: action.action_name,
status: 'success',
duration_ms: Date.now() - start,
details: response
});
} catch (err) {
results.push({
action: action.action_name,
status: 'failed',
error: err.message
});
}
}
await sendTelegramNotification(results, payload, env);
await logDeployment(env.DB, commit_hash, branch, deploy_type, results);
return new Response(JSON.stringify({ status: 'complete', results }), {
headers: { 'Content-Type': 'application/json' }
});
}
};
```
Telegram Notification Formatter
```javascript
async function sendTelegramNotification(results, payload, env) {
const statusEmoji = results.every(r => r.status === 'success') ? '✅' : '⚠️';
const message = [
`${statusEmoji} *Deploy Complete — ${payload.deploy_type}*`,
`Commit: \`${payload.commit_hash.substring(0, 7)}\``,
`Branch: ${payload.branch}`,
'',
'*Actions:*',
...results.map(r => {
const icon = r.status === 'success' ? '✅' : '❌';
const time = r.duration_ms ? ` (${r.duration_ms}ms)` : '';
return `${icon} ${r.action}${time}`;
}),
`🔗 https://aisalonhub.com/admin/deploys/${payload.commit_hash}`
].join('\n');
await fetch(`https://api.telegram.org/bot${env.TELEGRAM_BOT_TOKEN}/sendMessage`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ chat_id: env.TELEGRAM_CHAT_ID, text: message, parse_mode: 'Markdown' })
});
}
```
CLI Trigger for Manual Actions
```bash
Trigger sitemap regeneration
npx aislonhub-ctl action run --action regenerate-sitemap --env production
Run full marketing pipeline for a deploy
npx aislonhub-ctl deploy notify --commit abc1234 --type full
Check last 5 deployments
npx aislonhub-ctl deploy status --limit 5
```
Results — Deployment Speed and Content Freshness Metrics
Since implementing the feedback loop:
| Metric | Before | After | Improvement |
|---|---|---|---|
| Deploy-to-distribution time | ~48 hours | ~90 seconds | 99.9% faster |
| Sitemap freshness | Weekly | Every deploy | 7x more frequent |
| SEO audit cadence | Monthly | Per-deploy | 30x more frequent |
| Content freshness score | 62/100 | 94/100 | +32 points |
| Social distribution latency | ~3 days | ~2 minutes | 99.95% faster |
| Marketing team hours saved/wk | 0 (manual) | ~6 hours | N/A |
These numbers come from three months of production data on aisalonhub.com. The D1 audit table records every action execution with precise timing.
Content Freshness Tracking
The pipeline scores each page based on last update, deploy recency, backlink changes, and SEO audit pass rate:
```sql
UPDATE pages SET freshness_score = (
SELECT ROUND((
CASE WHEN julianday('now') - julianday(updated_at) < 1 THEN 40 ELSE 0 END +
CASE WHEN julianday('now') - julianday(last_deploy_check) < 1 THEN 30 ELSE 0 END +
CASE WHEN backlink_count > 10 THEN 15 ELSE backlink_count END +
CASE WHEN seo_audit_pass_rate > 0.9 THEN 15 ELSE seo_audit_pass_rate * 15 END
))
);
```
Pages scoring below 70 trigger automated content refresh suggestions in the EmDash CMS dashboard.
Key Takeaways
1. **Deploy events are marketing events.** The webhook bridge eliminates latency and inconsistency between code deployment and content distribution.
2. **Cloudflare Workers + D1 provide a serverless action pipeline.** No dedicated infrastructure needed — the entire loop runs on the same platform as the site itself.
3. **Telegram as the notification hub.** Lightweight, mobile-first. A single channel replaces Slack notifications, email chains, and dashboards.
4. **EmDash CMS plugins give marketing control without code.** Developers build the pipeline; marketers configure it. Neither team becomes a bottleneck.
5. **Freshness metrics drive improvement.** By tracking scores per-deploy, the system surfaces stale content automatically.
6. **Start simple, measure everything.** The first version had three actions: sitemap, SEO audit, and Telegram notification. Each addition was data-driven via the D1 audit table.
---
*AiSalonHub's dev-to-marketing feedback loop is built on Cloudflare Workers, D1, and the EmDash CMS plugin system. Full source code and deployment templates are available in the repository.*