Bitzsoft.Integrations.OutboundCall.Huawei 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bitzsoft.Integrations.OutboundCall.Huawei --version 1.0.0
                    
NuGet\Install-Package Bitzsoft.Integrations.OutboundCall.Huawei -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.OutboundCall.Huawei" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.OutboundCall.Huawei" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.OutboundCall.Huawei" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.OutboundCall.Huawei --version 1.0.0
                    
#r "nuget: Bitzsoft.Integrations.OutboundCall.Huawei, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.OutboundCall.Huawei@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.OutboundCall.Huawei&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.OutboundCall.Huawei&version=1.0.0
                    
Install as a Cake Tool

Bitzsoft.Integrations.OutboundCall.Huawei

华为云 CEC(云客服)外呼实现 — 基于 CCS REST API(IAM AK/SK,SDK-HMAC-SHA256 签名),实现 IOutboundCallService 统一接口。

功能特性

  • 实现 IOutboundCallService 统一接口:创建 / 启动 / 暂停 / 恢复 / 停止外呼批次 + 批次列表 / 详情查询 + 通话记录查询
  • 完整批次生命周期:创建外呼批次 → 导入号码 → start / pause / resume / stop 动作控制
  • 华为云 IAM 鉴权:AK/SK 的 SDK-HMAC-SHA256 签名(Authorization 头携带 Credential / SignedHeaders / Signature),不修改 HttpClient.BaseAddress 以避免并发场景线程安全问题
  • 境内外主叫分离:基于 CreateCampaignRequest.Region 选择 Callers / OverseaCallers
  • 白名单 / 黑名单过滤:创建批次前自动过滤号码(复用 CallListFilter),过滤后无可用号码直接返回失败
  • 批次状态映射:将华为云状态(pending / running / paused / completed / stopped / failed 等)映射为统一 CampaignStatus

安装

.NET CLI

dotnet add package Bitzsoft.Integrations.OutboundCall.Huawei

PackageReference

<PackageReference Include="Bitzsoft.Integrations.OutboundCall.Huawei" Version="1.0.0" />

配置

appsettings.json

{
  "OutboundCall": {
    "AccessKeyId": "AKxxxxxxxxxxxxxxxx",
    "AccessKeySecret": "SKxxxxxxxxxxxxxxxx",
    "Region": "cn-north-4",
    "Callers": [ "01012345678" ],
    "OverseaCallers": [],
    "Whitelist": [ "5678" ],
    "RequireWhitelistInNonProduction": true
  }
}
配置项 说明 必填 默认值
AccessKeyId 华为云 IAM AK(AccessKeyId) 空字符串
AccessKeySecret 华为云 IAM SK(SecretAccessKey) 空字符串
Region 地域(如 cn-north-4 cn-north-4
Callers 境内主叫号码列表 空列表
OverseaCallers 境外主叫号码列表 空列表
Whitelist 白名单(防误呼,支持后缀匹配) null
RequireWhitelistInNonProduction 非生产环境强制白名单 true

注册服务

委托配置

using Bitzsoft.Integrations.OutboundCall;
// 命名空间 Microsoft.Extensions.DependencyInjection

builder.Services.AddHuaweiOutboundCall(options =>
{
    options.AccessKeyId = "AKxxxxxxxxxxxxxxxx";
    options.AccessKeySecret = "SKxxxxxxxxxxxxxxxx";
    options.Region = "cn-north-4";
    options.Callers = new() { "01012345678" };
});

从 IConfiguration 绑定

builder.Services.AddHuaweiOutboundCall(
    builder.Configuration.GetSection("OutboundCall"));

说明:AddHuaweiOutboundCall 接收 Action<OutboundCallOptions> 配置委托,绑定到 OutboundCallOptions,注册 HuaweiOutboundCallService 为 typed client(挂载请求审计日志),并注册为 IOutboundCallService 单例。

使用示例

创建批次 + 启动 + 控制

using Bitzsoft.Integrations.OutboundCall;
using Bitzsoft.Integrations.OutboundCall.Dtos;
using Bitzsoft.Integrations.OutboundCall.PhoneNumber;

public class HuaweiCallService
{
    private readonly IOutboundCallService _outbound;

    public HuaweiCallService(IOutboundCallService outbound) => _outbound = outbound;

    public async Task RunAsync(string[] rawPhones)
    {
        var (mainland, _) = PhoneNumberClassifier.Classify(rawPhones);

        // 1. 创建外呼批次(call_type 默认 predictive 预测式)
        var resp = await _outbound.CreateCampaignAsync(new CreateCampaignRequest
        {
            Name = "催办批次",
            Region = PhoneRegion.Mainland,
            Callees = mainland.ToList(),
            MaxAttempts = 2,
            StrategyType = "predictive"
        });

        // 2. 导入号码(向批次追加联系人)
        await _outbound.ImportContactsAsync(new ImportContactsRequest
        {
            CampaignId = resp.CampaignId,
            Contacts = new() { "0086139xxxxxxxx" }
        });

        // 3. 启动 / 暂停 / 恢复 / 停止
        await _outbound.StartCampaignAsync(new StartCampaignRequest { CampaignId = resp.CampaignId });
        await _outbound.PauseCampaignAsync(resp.CampaignId);
        await _outbound.ResumeCampaignAsync(resp.CampaignId);
        await _outbound.StopCampaignAsync(resp.CampaignId);
    }
}

查询批次与话单

// 查询批次列表
var campaigns = await _outbound.ListCampaignsAsync(pageIndex: 1, pageSize: 20);

// 查询单个批次详情
var detail = await _outbound.GetCampaignAsync(campaignId);

// 查询批次的通话记录
var records = await _outbound.QueryCallRecordsAsync(new QueryCallRecordsRequest
{
    CampaignId = campaignId,
    PageSize = 100
});

请求审计

内置 Bitzsoft.Integrations.RequestLogging 出站请求记录管道,默认使用 NullRequestLogStore 不持久化。

// ① 默认:启用记录管道但不持久化(日志丢弃)
services.AddHuaweiOutboundCall(options => { /* ... */ });

// ② 持久化:宿主注册 IRequestLogStore 实现后,所有出站请求自动落库
services.AddRequestLogging<MyRequestLogStore>(opts =>
{
    opts.MaxInMemoryBodyBytes = 64 * 1024; // 仅控制内存/加密临时文件切换,不截断正文
    opts.SensitiveFields.Add("AccessKeySecret"); // 额外脱敏字段
});
services.AddHuaweiOutboundCall(options => { /* ... */ });

安全说明

  • AK / SK:华为云 IAM 访问密钥必须通过环境变量或 Secret Manager 注入,禁止硬编码;SK 仅参与 HMAC-SHA256 签名计算,不出现在请求中
  • SDK-HMAC-SHA256 签名:每次请求实时计算签名并附加 X-Sdk-DateHost 头,请求经 HTTPS 发送到 {region}.ccs.myhuaweicloud.com
  • 区域隔离Region 决定接入点地域,需与开通 CEC 服务的区域一致
  • 白名单防护:开发 / 测试环境务必配置 Whitelist,避免误呼叫真实客户

依赖

说明
Bitzsoft.Integrations.OutboundCall 外呼抽象层(IOutboundCallService + OutboundCallOptions
Bitzsoft.Integrations.RequestLogging 出站请求审计日志管道
Microsoft.Extensions.Http IHttpClientFactory(typed client 连接池)
Microsoft.Extensions.Logging.Abstractions 日志抽象
Microsoft.Extensions.Options 选项模式(IOptionsMonitor<OutboundCallOptions>

相关包

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.OutboundCall.Huawei:

Package Downloads
Bitzsoft.Integrations.OutboundCall.All

外呼服务聚合包 — 包含全部供应商实现(腾讯云/阿里云/火山引擎/容联云/华为云/国际 Twilio/Vonage)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 132 8/3/2026
1.0.0 128 8/2/2026
1.0.0-alpha.10 58 7/26/2026
1.0.0-alpha.9 60 7/12/2026
1.0.0-alpha.8 67 7/1/2026
1.0.0-alpha.7 79 6/16/2026
1.0.0-alpha.6 77 6/16/2026