# @akson/cortex-slack 中文文档

规范地址：https://npmcn.com/package/%40akson/cortex-slack/

版本：2\.1\.1
npm 元数据更新时间：2026-03-19T11:55:08.056Z
中文译文更新时间：2026-11-06T22:40:31.117Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40akson/cortex-slack
原文对照：https://npmcn.com/package/%40akson/cortex-slack/?lang=original
项目主页：https://github.com/antoineschaller/cortex-packages/tree/main/packages/slack
源码仓库：https://github.com/antoineschaller/cortex-packages

弃用说明：Deprecated: replaced by @slack/webhook\. No longer maintained\.

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：72 kB，22 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.0\.0
- 运行依赖：3 个
- 首次发布：2025-09-13T10:27:54.445Z
- 最新版本发布：2025-10-06T11:48:22.957Z
- 近 30 天下载量：2239（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 0 个）

## 中文简介

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

## 安装

```sh
npm install @akson/cortex-slack
```

也可以使用：`pnpm add @akson/cortex-slack`、`yarn add @akson/cortex-slack`、`bun add @akson/cortex-slack`

## README

# @akson/ cortex- slack (韩语)

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

## 特征

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

## 安装

```bash
npm install @akson/cortex-slack
```

## 快速启动

### 基本用途

```typescript
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%'
  }
});
```

### 环境变量

```bash
# 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
```

### 从环境创建

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

const slack = createSlackClientFromEnv();
```

## 用法实例

### 铅通知

```typescript
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()
});
```

### 错误通知

```typescript
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
  }
});
```

### 计量提醒

```typescript
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'
});
```

### 任务管理

```typescript
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'
});
```

### 每日情报报告

```typescript
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'
  ]
});
```

## 与我的军队情报部门合并

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

```typescript
// 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

```typescript
// 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');
```

### 从我的军队情报部门

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

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

## 测试

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

## 许可证

麻省理工学院

## 常见问题

### @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。作者已将其标记为弃用，新项目建议寻找替代方案。

