Skip to content

CheckStaffing ​

Branch the flow based on agent availability and staffing metrics.

Signatures ​

CheckStaffing (Current Queue Context) ​

Chaining Overload ​

csharp
ICheckStaffingBranchBuilder CheckStaffing(
    StaffingMetricType metricType = StaffingMetricType.Available,
    string? identifier = null)
ParameterTypeRequiredDescription
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
identifierstring?NoOptional identifier for the action

Return Value: ICheckStaffingBranchBuilder with methods:

  • .OnTrue(Action<IFlowBuilder>) - Branch when condition is true
  • .OnFalse(Action<IFlowBuilder>) - Branch when condition is false
  • .OnError(Action<IFlowBuilder>) - Branch when an error occurs

Inline Overload ​

csharp
IFlowBuilder CheckStaffing(
    Action<ICheckStaffingBranchesBuilder> branches,
    StaffingMetricType metricType = StaffingMetricType.Available,
    Action<CheckStaffingAction>? configure = null,
    string? identifier = null)
ParameterTypeRequiredDescription
branchesAction<ICheckStaffingBranchesBuilder>YesCallback to configure branch logic
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
configureAction<CheckStaffingAction>?NoOptional configuration for the action
identifierstring?NoOptional identifier for the action

Return Value: IFlowBuilder for continued flow chaining


CheckStaffingForQueue (Specific Queue) ​

Chaining Overload ​

csharp
ICheckStaffingBranchBuilder CheckStaffingForQueue(
    string queueNameOrArn,
    StaffingMetricType metricType = StaffingMetricType.Available,
    string? identifier = null)
ParameterTypeRequiredDescription
queueNameOrArnstringYesQueue name or ARN to check
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
identifierstring?NoOptional identifier for the action

Return Value: ICheckStaffingBranchBuilder with methods:

  • .OnTrue(Action<IFlowBuilder>) - Branch when condition is true
  • .OnFalse(Action<IFlowBuilder>) - Branch when condition is false
  • .OnError(Action<IFlowBuilder>) - Branch when an error occurs

Inline Overload ​

csharp
IFlowBuilder CheckStaffingForQueue(
    string queueNameOrArn,
    Action<ICheckStaffingBranchesBuilder> branches,
    StaffingMetricType metricType = StaffingMetricType.Available,
    Action<CheckStaffingAction>? configure = null,
    string? identifier = null)
ParameterTypeRequiredDescription
queueNameOrArnstringYesQueue name or ARN to check
branchesAction<ICheckStaffingBranchesBuilder>YesCallback to configure branch logic
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
configureAction<CheckStaffingAction>?NoOptional configuration for the action
identifierstring?NoOptional identifier for the action

Return Value: IFlowBuilder for continued flow chaining


CheckStaffingForAgent (Specific Agent) ​

Chaining Overload ​

csharp
ICheckStaffingBranchBuilder CheckStaffingForAgent(
    string agentArn,
    StaffingMetricType metricType = StaffingMetricType.Available,
    string? identifier = null)
ParameterTypeRequiredDescription
agentArnstringYesAgent ARN to check
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
identifierstring?NoOptional identifier for the action

Return Value: ICheckStaffingBranchBuilder with methods:

  • .OnTrue(Action<IFlowBuilder>) - Branch when condition is true
  • .OnFalse(Action<IFlowBuilder>) - Branch when condition is false
  • .OnError(Action<IFlowBuilder>) - Branch when an error occurs

Inline Overload ​

csharp
IFlowBuilder CheckStaffingForAgent(
    string agentArn,
    Action<ICheckStaffingBranchesBuilder> branches,
    StaffingMetricType metricType = StaffingMetricType.Available,
    Action<CheckStaffingAction>? configure = null,
    string? identifier = null)
ParameterTypeRequiredDescription
agentArnstringYesAgent ARN to check
branchesAction<ICheckStaffingBranchesBuilder>YesCallback to configure branch logic
metricTypeStaffingMetricTypeNoType of staffing metric (default: Available)
configureAction<CheckStaffingAction>?NoOptional configuration for the action
identifierstring?NoOptional identifier for the action

Return Value: IFlowBuilder for continued flow chaining


StaffingMetricType Values ​

ValueDescription
AvailableAgents ready to take calls (not on call, not in ACW)
StaffedAgents logged in and assigned to queue (may be busy)
OnlineAgents logged into the system

Examples ​

Basic Availability Check ​

csharp
Flow.Create("Staffing Aware")
    .PlayPrompt("Welcome to Nick Software.")
    .CheckStaffingForQueue("SupportQueue", StaffingMetricType.Available)
        .OnTrue(available => available
            .PlayPrompt("An agent is available to help you.")
            .TransferToQueue("SupportQueue")
            .Disconnect())
        .OnFalse(unavailable => unavailable
            .PlayPrompt("All agents are busy. You will be placed in the queue.")
            .TransferToQueue("SupportQueue")
            .Disconnect())
        .OnError(error => error
            .PlayPrompt("Transferring your call.")
            .TransferToQueue("SupportQueue")
            .Disconnect());

Multi-Level Staffing Check ​

csharp
Flow.Create("Smart Queue Routing")
    .PlayPrompt("Let me check agent availability.")

    // First check if anyone is available
    .CheckStaffingForQueue("SupportQueue", StaffingMetricType.Available)
        .OnTrue(available => available
            .PlayPrompt("Great! An agent is ready to assist.")
            .TransferToQueue("SupportQueue")
            .Disconnect())
        .OnFalse(notAvailable => notAvailable
            // No one available - check if anyone is staffed (logged in but busy)
            .CheckStaffingForQueue("SupportQueue", StaffingMetricType.Staffed)
                .OnTrue(staffed => staffed
                    .PlayPrompt("Agents are busy. Would you like to wait?")
                    .GetCustomerInput("Press 1 to wait, or 2 for a callback.")
                        .OnDigit("1", wait => wait
                            .TransferToQueue("SupportQueue")
                            .Disconnect())
                        .OnDigit("2", callback => callback
                            .PlayPrompt("We'll call you back.")
                            .Disconnect())
                        .OnTimeout(t => t.TransferToQueue("SupportQueue").Disconnect())
                        .OnDefault(d => d.TransferToQueue("SupportQueue").Disconnect()))
                .OnFalse(noStaff => noStaff
                    .PlayPrompt("No agents are currently available. Please call back later.")
                    .Disconnect())
                .OnError(e => e.TransferToQueue("SupportQueue").Disconnect()))
        .OnError(e => e.TransferToQueue("SupportQueue").Disconnect());

Combined with Hours Check ​

csharp
Flow.Create("Intelligent Routing")
    .CheckHoursOfOperation("BusinessHours")
        .OnInHours(open => open
            .CheckStaffingForQueue("Support", StaffingMetricType.Available)
                .OnTrue(available => available
                    .TransferToQueue("Support"))
                .OnFalse(unavailable => unavailable
                    .CheckStaffingForQueue("Support", StaffingMetricType.Staffed)
                        .OnTrue(staffed => staffed
                            .PlayPrompt("High call volume. Please hold.")
                            .TransferToQueue("Support"))
                        .OnFalse(noStaff => noStaff
                            .PlayPrompt("Unexpected staffing issue. Please hold.")
                            .TransferToQueue("Support"))
                        .OnError(e => e.TransferToQueue("Support")))
                .OnError(e => e.TransferToQueue("Support")))
        .OnOutOfHours(closed => closed
            .PlayPrompt("We're closed.")
            .Disconnect())
        .OnError(e => e.TransferToQueue("Support"))
    .Disconnect();

Queue Fallback Pattern ​

csharp
Flow.Create("Queue Fallback")
    .PlayPrompt("Checking availability.")

    // Try primary queue
    .CheckStaffingForQueue("PrimarySupport", StaffingMetricType.Available)
        .OnTrue(primary => primary
            .TransferToQueue("PrimarySupport")
            .Disconnect())
        .OnFalse(noPrimary => noPrimary
            // Try secondary queue
            .CheckStaffingForQueue("SecondarySupport", StaffingMetricType.Available)
                .OnTrue(secondary => secondary
                    .PlayPrompt("Connecting to our overflow team.")
                    .TransferToQueue("SecondarySupport")
                    .Disconnect())
                .OnFalse(noSecondary => noSecondary
                    // Try sales as last resort
                    .CheckStaffingForQueue("Sales", StaffingMetricType.Available)
                        .OnTrue(sales => sales
                            .PlayPrompt("Connecting to an available agent.")
                            .TransferToQueue("Sales")
                            .Disconnect())
                        .OnFalse(noSales => noSales
                            .PlayPrompt("All lines are busy. Please call back later.")
                            .Disconnect())
                        .OnError(e => e.TransferToQueue("PrimarySupport").Disconnect()))
                .OnError(e => e.TransferToQueue("PrimarySupport").Disconnect()))
        .OnError(e => e.TransferToQueue("PrimarySupport").Disconnect());

VIP Priority Routing ​

csharp
Flow.Create("VIP Routing")
    .InvokeLambda("GetCustomerInfo")
        .OnSuccess(s => s.SetContactAttributes(a => a["Tier"] = Attributes.External("Tier")))
        .OnError(e => e.TransferToQueue("General").Disconnect())

    .CheckContactAttribute(check =>
    {
        check.Attribute(Attributes.Contact("Tier"))
            .Equals("VIP", vip => vip
                // VIP always gets transferred, check just for messaging
                .CheckStaffingForQueue("VIPSupport", StaffingMetricType.Available)
                    .OnTrue(available => available
                        .PlayPrompt("A VIP specialist is ready for you.")
                        .TransferToQueue("VIPSupport"))
                    .OnFalse(unavailable => unavailable
                        .PlayPrompt("Your call is priority. Next available VIP specialist.")
                        .TransferToQueue("VIPSupport"))
                    .OnError(e => e.TransferToQueue("VIPSupport")))
            .Otherwise(regular => regular
                .CheckStaffingForQueue("General", StaffingMetricType.Available)
                    .OnTrue(available => available
                        .TransferToQueue("General"))
                    .OnFalse(unavailable => unavailable
                        .PlayPrompt("Please hold for the next available agent.")
                        .TransferToQueue("General"))
                    .OnError(e => e.TransferToQueue("General")));
    })
    .Disconnect();

Using Current Queue Context ​

csharp
Flow.Create("Queue Context Check")
    // Set working queue first
    .SetWorkingQueue("Support")

    // CheckStaffing uses current queue context
    .CheckStaffing(StaffingMetricType.Available)
        .OnTrue(available => available
            .PlayPrompt("Agent available.")
            .TransferToQueue("Support"))
        .OnFalse(unavailable => unavailable
            .PlayPrompt("Please hold."))
        .OnError(e => e.TransferToQueue("Support"))
    .Disconnect();

Understanding Metric Types ​

MetricTrue WhenUse Case
AvailableAt least one agent is ready to take a callBest customer experience messaging
StaffedAt least one agent is logged in to the queueDetermining if queue is operational
OnlineAt least one agent is logged into ConnectSystem health check

Staffing Hierarchy ​

Online (broadest)
  └── Staffed (subset - assigned to queue)
        └── Available (subset - ready to take calls)

Chaining vs. Inline Patterns ​

Switchboard provides two complementary patterns for CheckStaffing, CheckStaffingForQueue, and CheckStaffingForAgent:

Chaining Overload: Use when you need to execute additional flow steps after the staffing check (at the parent level).

csharp
.CheckStaffingForQueue(queueArn, StaffingMetricType.Available)
    .OnTrue(...)
    .OnFalse(...)
    .OnError(...)
.PlayPrompt("Checking complete")  // Executes after staffing check completes
.Build();

Inline Overload: Use when branch logic is self-contained and you don't need parent-level actions after the staffing check.

csharp
.CheckStaffingForQueue(queueArn, branches => branches
    .OnTrue(...)
    .OnFalse(...)
    .OnError(...))
.PlayPrompt("Continuing main flow")  // Continues building the parent flow
.Build();

For real-world examples using dependency injection and resource registries, see examples/SimpleCallCenter/Flows/StaffingAwareFlowBuilder.cs.

AWS Connect Block Type ​

This block generates the CheckStaffing action type in the exported flow JSON.

Best Practices ​

  1. Use Available for customer messaging - Most accurate for "agent ready" scenarios
  2. Use Staffed for queue health - Determines if queue is operational
  3. Always handle OnError - Staffing checks can fail
  4. Provide fallback queues - Don't strand customers
  5. Don't over-promise - "Available" can change between check and transfer

See Also ​

Preview release - Licensing terms TBD before 1.0