NickSoftware.Switchboard.Extensions.DependencyInjection 0.1.0-preview.52

This is a prerelease version of NickSoftware.Switchboard.Extensions.DependencyInjection.
This package has a SemVer 2.0.0 package version: 0.1.0-preview.52+f70eb54.
dotnet add package NickSoftware.Switchboard.Extensions.DependencyInjection --version 0.1.0-preview.52
                    
NuGet\Install-Package NickSoftware.Switchboard.Extensions.DependencyInjection -Version 0.1.0-preview.52
                    
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="NickSoftware.Switchboard.Extensions.DependencyInjection" Version="0.1.0-preview.52" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NickSoftware.Switchboard.Extensions.DependencyInjection" Version="0.1.0-preview.52" />
                    
Directory.Packages.props
<PackageReference Include="NickSoftware.Switchboard.Extensions.DependencyInjection" />
                    
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 NickSoftware.Switchboard.Extensions.DependencyInjection --version 0.1.0-preview.52
                    
#r "nuget: NickSoftware.Switchboard.Extensions.DependencyInjection, 0.1.0-preview.52"
                    
#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 NickSoftware.Switchboard.Extensions.DependencyInjection@0.1.0-preview.52
                    
#: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=NickSoftware.Switchboard.Extensions.DependencyInjection&version=0.1.0-preview.52&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NickSoftware.Switchboard.Extensions.DependencyInjection&version=0.1.0-preview.52&prerelease
                    
Install as a Cake Tool

Switchboard Dependency Injection Extensions

Dependency injection and IoC container extensions for the Switchboard Amazon Connect framework.

NuGet

⚠️ PREVIEW RELEASE: Part of the Switchboard preview release. APIs may change.

Overview

This package provides Microsoft.Extensions.DependencyInjection integration for the Switchboard framework, enabling:

  • Automatic assembly scanning for flow builders and providers
  • Middleware pipeline registration
  • Configuration binding from appsettings.json
  • Service lifetime management

Installation

dotnet add package NickSoftware.Switchboard.Extensions.DependencyInjection --prerelease

This package is typically installed alongside the main Switchboard package:

dotnet add package NickSoftware.Switchboard --prerelease
dotnet add package NickSoftware.Switchboard.Extensions.DependencyInjection --prerelease

Quick Start

Basic Setup

using Switchboard.Extensions.DependencyInjection;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddSwitchboard(options =>
{
    options.InstanceName = "MyCallCenter";
    options.Region = "us-east-1";
});

var host = builder.Build();
var app = host.Services.GetRequiredService<ISwitchboardApp>();

With Configuration

// Using appsettings.json
builder.Services.AddSwitchboard(builder.Configuration);
// appsettings.json
{
  "Switchboard": {
    "InstanceName": "MyCallCenter",
    "Region": "us-east-1",
    "EnableLogging": true
  }
}

Features

Assembly Scanning

Automatically discover and register flow builders and resource providers:

builder.Services.AddSwitchboard(options => { })
    .AddAssemblyScanning(typeof(Program).Assembly);

Flow builders are discovered by:

  • Implementing IDiscoverableFlowBuilder interface
  • Decorating with [FlowBuilder] attribute
// Using interface
public class MainFlowBuilder : IDiscoverableFlowBuilder
{
    public IFlow Build() => Flow.Create("MainFlow")
        .PlayPrompt("Welcome")
        .Build();
}

// Using attribute
[FlowBuilder]
public class SupportFlowBuilder
{
    public IFlow Build() => Flow.Create("SupportFlow")
        .PlayPrompt("Support line")
        .Build();
}

Middleware Pipeline

Register and configure middleware for flow validation and processing:

builder.Services.AddSwitchboard(options => { })
    .UseMiddleware<LoggingMiddleware>()
    .UseMiddleware<ValidationMiddleware>()
    .UseMiddleware<MetricsMiddleware>();

Built-in middleware:

  • LoggingMiddleware - Logs flow building and validation
  • ValidationMiddleware - Validates flow structure
  • LambdaValidationMiddleware - Validates Lambda configurations
  • MetricsMiddleware - Collects build metrics

Custom Middleware

public class CustomMiddleware : IFlowMiddleware
{
    private readonly ILogger<CustomMiddleware> _logger;

    public CustomMiddleware(ILogger<CustomMiddleware> logger)
    {
        _logger = logger;
    }

    public async Task InvokeAsync(FlowContext context, Func<Task> next)
    {
        _logger.LogInformation("Processing flow: {FlowName}", context.FlowName);
        await next();
        _logger.LogInformation("Flow processed successfully");
    }
}

Validation Configuration

Configure custom validators:

builder.Services.AddSwitchboard(options => { })
    .AddValidation(config =>
    {
        config.ValidateEmptyFlows = true;
        config.ValidateTerminalActions = true;
        config.ValidateTransitions = true;
    });

Resource Providers

Register configuration providers for queues, routing profiles, and hours of operation:

[ResourceProvider]
public class QueueProvider : IResourceProvider
{
    public void Configure(ISwitchboardStack stack)
    {
        stack.AddQueue(Queue.Create("Sales")
            .Build());
    }
}

Manual Registration

If you prefer explicit registration over scanning:

builder.Services.AddSwitchboard(options => { })
    .AddFlowBuilders(typeof(MainFlowBuilder), typeof(SupportFlowBuilder))
    .AddProviders(typeof(QueueProvider), typeof(HoursProvider));

Integration with Existing Connect Instance

builder.Services.AddSwitchboard(options =>
{
    options.InstanceArn = "arn:aws:connect:us-east-1:123456789:instance/abc-123";
});

Requirements

  • .NET 10.0 or later
  • Microsoft.Extensions.DependencyInjection 9.0+

Documentation


Part of the Switchboard framework for Amazon Connect

Product Compatible and additional computed target framework versions.
.NET 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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.52 41 12/3/2025
0.1.0-preview.51 43 12/2/2025
0.1.0-preview.48 37 12/2/2025
0.1.0-preview.47 37 12/1/2025
0.1.0-preview.46 31 12/1/2025
0.1.0-preview.45 38 11/30/2025
0.1.0-preview.44 42 11/30/2025
0.1.0-preview.43 33 11/30/2025
0.1.0-preview.42 45 11/30/2025

Preview release - APIs may change. See documentation at https://nicksoftware.github.io/switchboard-docs/