@akson/cortex-slack

中文文档
2.1.1发布于 2025/10/06MITTypeScriptESM + CJS近 30 天下载 2239

Cortex 生态系统的统一Slack集成 - webhoks, bot API和通知

此软件包已被标记为弃用

Deprecated: replaced by @slack/webhook. No longer maintained.

中文使用文档
文档目录18 节
  1. 特征
  2. 安装
  3. 快速启动
  4. 基本用途
  5. 环境变量
  6. 从环境创建
  7. 用法实例
  8. 铅通知
  9. 错误通知
  10. 计量提醒
  11. 任务管理
  12. 每日情报报告
  13. 与我的军队情报部门合并
  14. 移徙指南
  15. 从直接 Webhook
  16. 从我的军队情报部门
  17. 测试
  18. 许可证

@akson/ cortex- slack (韩语)

统一整合我的军队生态系统 提供集中通知、警报和报告能力.

特征

  • 🔔 Webhook 支持 - 通过Incoming Webhooks简单通知
  • 🤖 瓶子 API - 全面互动信息和按钮
  • 🚨 警报系统 - 基于严重性的警告,格式丰富
  • 📊 报告 - 每日/每周情报和市场报告
  • 🎯 铅追踪 - 实时牵头通知
  • ⚠️ 处理错误 - 集中的错误通知
  • 📈 计量 - 性能和阈值警报

安装

npm install @akson/cortex-slack

快速启动

基本用途

import { SlackClient } from '@akson/cortex-slack';

const slack = new SlackClient({
  webhookUrl: 'https://hooks.slack.com/services/YOUR/WEBHOOK/URL',
  botToken: 'xoxb-your-bot-token',
  channels: {
    alerts: '#alerts',
    leads: '#leads',
    reports: '#reports'
  }
});

// Send a simple alert
await slack.sendAlert({
  severity: 'warning',
  message: 'High memory usage detected',
  details: {
    usage: '85%',
    threshold: '80%'
  }
});

环境变量

# Webhook (for simple notifications)
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL

# Bot Token (for full API access)
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_ID=your-app-id
SLACK_TEAM_ID=your-team-id
SLACK_TEAM_NAME=your-team-name

# Channel Configuration
SLACK_CHANNEL_ALERTS=#alerts
SLACK_CHANNEL_TASKS=#tasks
SLACK_CHANNEL_REPORTS=#reports
SLACK_CHANNEL_LEADS=#leads
SLACK_CHANNEL_ERRORS=#errors

# Enable/Disable
SLACK_ENABLED=true

从环境创建

import { createSlackClientFromEnv } from '@akson/cortex-slack';

const slack = createSlackClientFromEnv();

用法实例

铅通知

await slack.sendLeadNotification({
  lead_id: 'LEAD-12345',
  phone: '+41791234567',
  products: ['Custom Badge', 'Unit Patch'],
  total_value: 249.90,
  source: 'WhatsApp',
  urgency: 'high',
  timestamp: new Date()
});

错误通知

await slack.sendErrorNotification({
  error: new Error('Database connection failed'),
  context: 'Lead Processing',
  severity: 'critical',
  stack: error.stack,
  metadata: {
    lead_id: 'LEAD-12345',
    retry_count: 3
  }
});

计量提醒

await slack.sendMetricAlert({
  metric: 'Conversion Rate',
  current_value: 1.2,
  threshold: 2.0,
  change_percentage: -40,
  trend: 'down',
  severity: 'warning',
  recommendation: 'Review landing page changes from last deployment'
});

任务管理

await slack.sendTaskReview({
  task: {
    id: 'TASK-001',
    title: 'Update SEO meta tags',
    description: 'Optimize meta descriptions for Swiss military keywords',
    type: 'seo',
    priority: 'high',
    confidence: 0.85,
    estimated_impact: 'High',
    created_at: new Date()
  },
  preview: {
    suggested_changes: [
      'Add "militär badge" to homepage title',
      'Update meta description with "funktionsabzeichen"'
    ]
  },
  action_required: 'Review and approve SEO changes'
});

每日情报报告

await slack.sendDailyIntelligenceReport({
  date: new Date(),
  sources_checked: 5,
  tasks_generated: 12,
  auto_executed: 8,
  manual_required: 4,
  swiss_market: {
    avg_position: 3.2,
    impressions: 15000,
    clicks: 450,
    ctr: 3.0
  },
  lead_funnel: {
    new_leads: 23,
    conversion_rate: 2.8,
    whatsapp_contacts: 15
  },
  alerts: [
    'Competitor bidding on brand keywords',
    'CTR drop on mobile devices'
  ],
  recommendations: [
    'Increase mobile page speed',
    'Add more Swiss German content'
  ]
});

与我的军队情报部门合并

这个套件旨在与我的陆军情报系统无缝地工作:

// In myarmy-intelligence
import { SlackClient } from '@akson/cortex-slack';

const slack = new SlackClient({
  botToken: process.env.SLACK_BOT_TOKEN,
  channels: {
    alerts: '#intelligence-alerts',
    tasks: '#intelligence-tasks',
    reports: '#intelligence-reports'
  }
});

// Use for automated alerts
await slack.sendAlert({
  severity: 'critical',
  message: 'Brand bidding violation detected',
  details: {
    competitor: 'Competitor X',
    keyword: 'myarmy',
    position: 1
  }
});

移徙指南

从直接 Webhook

// Old way
await fetch(SLACK_WEBHOOK_URL, {
  method: 'POST',
  body: JSON.stringify({ text: 'Hello' })
});

// New way
import { SlackClient } from '@akson/cortex-slack';
const slack = new SlackClient({ webhookUrl: SLACK_WEBHOOK_URL });
await slack.sendWebhookMessage('Hello');

从我的军队情报部门

// Old way (custom implementation)
import { SlackNotifier } from './integrations/slack';

// New way
import { SlackClient } from '@akson/cortex-slack';
const slack = new SlackClient(config);

测试

// Test connection
const isConnected = await slack.testConnection();
console.log('Slack connected:', isConnected);

许可证

麻省理工学院

版本与发布记录

@akson/cortex-slack 共发布 3 个版本,首次发布于 2025/09/13;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.1.1latest2025/10/061.1 年前
2.1.02025/10/061.1 年前
2.0.02025/09/131.1 年前

关于 @akson/cortex-slack 的常见问题

@akson/cortex-slack 是什么?

Cortex 生态系统的统一Slack集成 - webhoks, bot API和通知注意:该包已被作者标记为弃用——Deprecated: replaced by @slack/webhook. No longer maintained.

如何安装 @akson/cortex-slack?

在项目目录运行 npm install @akson/cortex-slack,或使用 pnpm add / yarn add / bun add。

@akson/cortex-slack 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@akson/cortex-slack 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@akson/cortex-slack 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@akson/cortex-slack 可以商用吗?

@akson/cortex-slack 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@akson/cortex-slack 的下载量有多少?

根据 npm 官方下载统计,@akson/cortex-slack 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,239 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@akson/cortex-slack 还在维护吗?

最新版本 2.1.1 发布于 2025/10/06(1.1 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/09/13。作者已将其标记为弃用,新项目建议寻找替代方案。