

# Flow control actions in the Amazon Connect Flow language
Flow control actions

These actions don't have any side effects and are only used to determine the path through a flow. Certain data may not be available (such as contact data, if the action is determining its path based on contact data). These actions generally work in every circumstance.

A flow control action is an action that:
+ Does not need a contact or a participant to succeed.
+ Controls the behavior of the flow, by either enabling or disabling flow behavior (such as logging) or by choosing a branch when the flow runs.

**Topics**
+ [CheckHoursOfOperation](flow-control-actions-checkhoursofoperation.md)
+ [CheckMetricData](flow-control-actions-checkmetricdata.md)
+ [CheckOutboundCallStatus](flow-control-actions-checkoutboundcallstatus.md)
+ [CheckVoiceId](flow-control-actions-checkvoiceid.md)
+ [Compare](flow-control-actions-compare.md)
+ [DistributeByPercentage](flow-control-actions-distributebypercentage.md)
+ [EndFlowExecution](flow-control-actions-endflowexecution.md)
+ [GetMetricData](flow-control-actions-getmetricdata.md)
+ [Loop](flow-control-actions-loop.md)
+ [StartVoiceIdStream](flow-control-actions-startvoiceidstream.md)
+ [TransferToFlow](flow-control-actions-transfertoflow.md)
+ [UpdateFlowAttributes](flow-control-actions-updateflowattributes.md)
+ [UpdateFlowLoggingBehavior](flow-control-actions-updateflowloggingbehavior.md)
+ [UpdateRoutingCriteria](flow-control-actions-updateroutingcriteria.md)
+ [Wait](flow-control-actions-wait.md)

# CheckHoursOfOperation
CheckHoursOfOperation

Returns whether the specified hours of operation object (or the hours of operation object associated with the current queue if no hours of operation is referenced) is in hours or out of hours as its result, allowing comparisons against it. 

## Parameter object


```
{ 
  "HoursOfOperationId": [Optional] An hours of operation ID or hours of operation ARN. *Must be either fully static or fully dynamic*. If not specified, the TargetQueue's hours of operation for the contact are used
}
```

## Results and conditions


**True** or **False** based on whether the hours of operation object specified is in hours or out of hours. There must be a Condition provided for Equals **True** and a Condition for Equals **False**, and no other conditions.

## Errors

+ NoMatchingError - if no other Error matches.

## Restrictions


This action is available in inbound flows, transfer flows, and customer queue flows. It is not available to hold flows or to whisper flows. 

## Corresponding block in the UI


[Check hours of operation](https://docs.aws.amazon.com/connect/latest/adminguide/check-hours-of-operation.html) 

# CheckMetricData
CheckMetricData

A shortcut single action to avoid using GetMetricData and Compare for a set of simple metrics. This action loads the specified metric data for the specified queue, and allows comparisons to the loaded value. For example, it loads number of contacts in queue, age of oldest contact in queue, number of agents staffed on the queue, number of agents available on the queue, or number of agents online on the queue. 

## Parameter object


```
{
  "MetricType": One of [NumberOfAgentsAvailable, NumberOfAgentsStaffed, NumberOfAgentsOnline, OldestContactInQueueAgeSeconds, NumberOfContactsInQueue]. **Dynamic values are not supported**,
  "QueueId": [Optional] A queue ID or queue ARN. If AgentId is specified, this may not be specified. *Dynamic values are supported*,
  "AgentId": [Optional] An agent ID or agent ARN, representing an agent queue. If QueueId is specified, this may not be specified. *Dynamic values are supported*. If neither this nor QueueId are specified, the contact TargetQueue is used
}
```

## Execution results and conditions


A number, representing the value of the metric that was requested. This can be used for conditions. If the MetricType is NumberOfAgents\$1 then the only supported condition is "NumberGreaterThan 0", otherwise Equals and any Number\$1 Operands are allowed.

## Errors

+ NoMatchingError - if no other Error matches.
+ NoMatchingCondition - if no other Condition matches (only supported if the MetricType is OldestContactInQueueAgeSeconds or NumberOfContactsInQueue).

## Restrictions


This action is only usable in flows, queue and agent transfers, and customer queue flows. It is not available in any type of whisper or hold flows. 

## Corresponding block in the UI

+ [Check staffing](https://docs.aws.amazon.com/connect/latest/adminguide/check-staffing.html) 
+ [Check queue status](https://docs.aws.amazon.com/connect/latest/adminguide/check-queue-status.html) 

# CheckOutboundCallStatus
CheckOutboundCallStatus

Engages with the output provided by an answering machine, and provides branches to route the contact accordingly.

## Parameter object


```
{
 
}
```

## Execution results and conditions

+ "CallAnswered" if the call has been answered by a person.
+ "VoicemailBeep" if Amazon Connect identifies that the call ended in a voice mail and it detects a beep.
+ "VoicemailNoBeep" if Amazon Connect identifies that call ended in a voicemail, but it doesn't detect a beep, or the beep is unknown.
+ "NotDetected" if Amazon Connect could not detect whether there is a voicemail. This happens when Amazon Connect is unable to make a positive determination of whether a call was answered by a live voice or an answering machine. Typical situations that result in this state include long silences or excessive background noise.

Conditions are supported, but only the "Equals" operator is supported. "CallAnswered", "VoicemailBeep" , "VoicemailNoBeep" and "NotDetected" are the only supported operands.

## Errors

+ NoMatchingError if no condition matches.

## Restrictions


This action works with [Amazon Connect outbound campaigns](https://docs.aws.amazon.com/connect/latest/adminguide/enable-outbound-campaigns.html) only. 

## Corresponding block in the UI


[Check call progress](https://docs.aws.amazon.com/connect/latest/adminguide/check-call-progress.html) 

# CheckVoiceId
CheckVoiceId

Checks the enrollment status, voice authentication or fraud detection results of the voice analysis returned by Voice ID. 

## Parameter object


```
{
 "CheckVoiceIdOption": "enrollmentStatus"
}
```

```
{
 "CheckVoiceIdOption": "voiceAuthentication"
}
```

```
{
 "CheckVoiceIdOption": "fraudDetection"
}
```

## Execution results and conditions


The checkVoiceId action returns results of the voice analysis and the status returned by Voice ID. The following is returned when CheckVoiceIdOption input is set as: 
+ **enrollmentStatus**: 
  + **Enrolled**: The caller is enrolled in voice authentication.
  + **Not enrolled**: The caller has not yet been enrolled in voice authentication. When this status is returned, for example, you may want to directly route the call to an agent for enrollment.
  + **Opted out**: The caller has opted out of voice authentication.

  You are not charged for checking enrollment status. 
+ **voiceAuthentication**:
  + **Authenticated**: The caller's identity has been verified. That is, the authentication score is greater than or equal to the threshold (default threshold of 90 or your custom threshold).
  + **Not authenticated**: The authentication score is lower than threshold that you configured.
  + **Inconclusive**: Unable to analyze a caller's speech for authentication. This is usually because Voice ID did not get the required 10 seconds to provide a result for authentication. 
  + **Not enrolled**: The caller has not yet been enrolled in voice authentication. When this status is returned, for example, you may want to directly route the call to an agent for enrollment.
  + **Opted out**: The caller has opted out of voice authentication.

  You are not charged if the result is **Inconclusive**, **Not enrolled** or **Opted out**.
+ **fraudDetection**: 
  + **High risk**: The risk score meets or exceeds the set threshold.
  + **Low risk**: The risk score did not meet the set threshold.
  + **Inconclusive**: Unable to analyze a caller's voice for detection of fraudsters in a watchlist.

## Errors

+ NoMatchingError if no condition matches.

## Restrictions


Only supported for voice channel. If used with the chat or task channels, the action takes the **Error** branch. 

## Corresponding block in the UI


[Check Voice ID](https://docs.aws.amazon.com/connect/latest/adminguide/check-voice-id.html) 

# Compare
Compare

Allows comparisons against the specified value. 

## Parameter object


```
{
  "ComparisonValue": Any **single** JSONPath identifier that is valid for the flow data object
}
```

## Execution results and conditions


The value specified for comparison. This can be used for conditions.

## Errors

+ NoMatchingCondition - if no other Condition matches. 

## Restrictions


This action is available in every type of flow. 

## Corresponding block in the UI


[Check contact attributes](https://docs.aws.amazon.com/connect/latest/adminguide/check-contact-attributes.html) 

# DistributeByPercentage
DistributeByPercentage

Returns a random number between 1 and 100 (inclusive) as its result, allowing comparisons against it. 

## Parameter object


```
{
                
}
```

## Results and conditions


A number between 1 and 100, inclusive, chosen randomly. Comparisons are supported, but they must be a chain of NumericLessThan comparisons, with each subsequent comparison checking the previous value, plus the percentage that is desired to go down this next action, and no Comparison comparing a value larger than 100.

## Errors

+ NoMatchingCondition if no Condition matches. This is the default option in the flow editor.

## Restrictions


This action is available in inbound flows, transfer flows, and customer queue flows. It is not available to hold flows or to whisper flows. 

## Corresponding block in the UI


[Distribute by percentage](https://docs.aws.amazon.com/connect/latest/adminguide/distribute-by-percentage.html) 

# EndFlowExecution
EndFlowExecution

Finishes flow, but does not explicitly disconnect the participant. The participant may be disconnected by contact logic after this. For example, if a flow ends before the contact is put into queue, ending the flow results in the contact being ended. 

## Parameter object


```
{
   
}
```

## Results and conditions


None. No conditions are supported.

## Errors


None. This is always a terminal action.

## Restrictions


This action is available only in whisper flows and customer queue flows. It is not available in flows, hold flows, or transfer flows. 

## Corresponding block in the UI


[End flow / Resume](https://docs.aws.amazon.com/connect/latest/adminguide/end-flow-resume.html) 

# GetMetricData
GetMetricData

Loads real time queue metrics for the queue specified by queue ID, agent ID (for agent queues), or the target queue, and makes them available on the flow run data. May be extended in the future to allow getting historical metric data in addition to current metric data, and to getting agent metrics in addition to queue metrics. 

## Parameter object


```
{ 
  "QueueId": [Optional] A queue ID or queue ARN. If AgentId is specified, this may not be specified. *Dynamic values are supported*,
  "AgentId": [Optional] An agent ID or agent ARN, representing an agent queue. If QueueId is specified, this may not be specified. *Dynamic values are supported*
  "QueueChannel": [Optional] Either "Voice" or "Chat". Can be set dynamically. Determines the channel for which metrics are returned. If not specified, metrics are returned for all channels.
}
```

## Execution results and conditions


None. No conditions are supported.

## Errors

+ NoMatchingError - if no other Error matches.

## Restrictions


This action is available in every type of flow. 

## Corresponding block in the UI


[Get queue metrics](https://docs.aws.amazon.com/connect/latest/adminguide/get-queue-metrics.html) 

# Loop
Loop

When the same action (the same Action Identifier) is run multiple times, this block returns a result of "NotDone" a number of times equal to the specified loop count, then "Done" once, then reset. 

## Parameter object


```
{
    "LoopCount": Number of times to loop, must be between 0 and 100 (inclusive). Must either be fully static or fully dynamic.
}
```

## Execution results and conditions


"ContinueLooping" if the loop should continue. "DoneLooping" if the loop should finish. Conditions are supported, there must be a Condition provided for Equals ContinueLooping and for Equals DoneLooping, and no other Conditions can be specified.

## Errors


None.

## Restrictions


This is supported in every type of flow. 

## Corresponding block in the UI


[Loop](https://docs.aws.amazon.com/connect/latest/adminguide/loop.html) 

# StartVoiceIdStream
StartVoiceIdStream

Sends audio to Amazon Connect Voice ID to verify the caller's identity and match against fraudsters in watchlist, as soon as the call is connected to a flow.

## Parameter object


```
{
 
}
```

## Execution results and conditions


None. No conditions are supported. 

## Errors

+ NoMatchingError if no condition matches.

## Restrictions


Only supported for the voice channel. If used with the chat or task channels, the action takes the **Error** branch. Not supported in hold flows.

## Corresponding block in the UI


[Set Voice ID](https://docs.aws.amazon.com/connect/latest/adminguide/set-voice-id.html) 

# TransferToFlow
TransferToFlow

Execution jumps to a different flow, and continues running at that flow's beginning. 

## Parameter object


```
{
    "ContactFlowId": A flow ID or flow ARN. *Must be either fully static or a single valid JSONPath identifier*
}
```

## Execution results and conditions


None.

## Errors

+ NoMatchingError - if no other Error matches.

## Restrictions


This action is available in inbound flows and transfer flows. It is not available to hold flows, customer queue flows, or whisper flows. 

## Corresponding block in the UI


[Transfer to flow](https://docs.aws.amazon.com/connect/latest/adminguide/transfer-to-flow.html) 

# UpdateFlowAttributes
UpdateFlowAttributes

Sets a collection of attributes on the current flow. These attributes are not carried over to the subsequent flows. With this type of operation, either all attributes are set or none are set.

## Parameter object


```
{
    ""FlowAttributes": { An Object that holds the attributes to be set. Keys are of type String, Values are of type FlowAttribute
        "Type": {
            FlowAttribute" : "Value"
        }
    }
}
```

## Results and conditions


None. No conditions are supported.

## Errors


None.

## Restrictions


This action is supported on all channels and in all flow types. 

## Corresponding block in the UI


[Set contact attributes](https://docs.aws.amazon.com/connect/latest/adminguide/set-contact-attributes.html) 

# UpdateFlowLoggingBehavior
UpdateFlowLoggingBehavior

Enables or disables flow logging. If this is a flow, this same behavior remains unless it is overridden for the rest of the contact segment. It is also automatically inherited by new segments in the chain. 

## Parameter object


```
{ 
  "FlowLoggingBehavior": One of [Enabled,Disabled]. *Dynamic values are not supported*
}
```

## Results and conditions


None. No conditions are supported.

## Errors


None.

## Restrictions


This action is available in every type of flow. 

## Corresponding block in the UI


[Set logging behavior](https://docs.aws.amazon.com/connect/latest/adminguide/set-logging-behavior.html) 

# UpdateRoutingCriteria
UpdateRoutingCriteria

Sets the routing criteria for the contact. 

## Parameter object


```
{
    "RoutingCriteria": { Required. RoutingCriteria is a JSON object.
            "Steps": [{  Required. List of routing steps. When Amazon Connect not find an available agent meeting the requirements in a step for a given step duration, the routing criteria will move on to the next step sequentially until a join is completed with an agent. When all steps are exhausted, the contact will be offered to any agent in the queue.  May be set statically or dynamically
                "Expression": { Required. An object to specify the expression of a routing step. It is a tagged union to specify expression for a routing step.
                    "AttributeCondition": {An object to specify the predefined attribute condition.
                        "Name": The name of predefined attribute. It is a string and has length constraints between 1-64.
                        "Value": The value of predefined attribute. It is a string and has length constraints between 1-64.
                        "ProficiencyLevel": The proficiency level of the condition. It is a float value. Valid values are: 1.0, 2.0, 3.0, 4.0 and 5.0
                        "ComparisonOperator": The operator of the condition. It is a string. Valid values: NumberGreaterOrEqualTo
                    }
                   "AndExpression": [List of routing expressions (attribute conditions) which will be AND-ed together.]
                },
                "Expiry": { An object to specify the expiration of a routing step.
                    "DurationInSeconds": The number of seconds to wait before expiring the routing step. Can be set only statically
                }
            }]
        }
}
```

## Results and conditions


None. No conditions are supported.

## Errors


NoMatchingError - if no other Error matches.

## Restrictions


This action is supported on all channels and in only in Inbound flow, Customer Queue flow, Transfer to Agent flow, and Transfer to Queue flow types.

## Corresponding block in the UI


[Set routing criteria](https://docs.aws.amazon.com/connect/latest/adminguide/set-routing-criteria.html) 

# Wait
Wait

Pauses the flow for a specified duration, or until a specified event happens, whichever happens first. 

## Parameter object


```
{
    "TimeoutSeconds": The amount of time to wait before the action finishes with the "WaitCompleted" result. This can be either statically defined, or a single valid JSONPath identifier. If defined statically, this must be a positive integer value no greater than 604800 (seven days),
    "Events": An optional list of all events that can trigger an interrupt. The supported events currently are "CustomerReturned" and "BotParticipantDisconnected". This must be defined statically.
  
}
```

## Execution results and conditions


If an event interrupts the wait, the run result is the event that interrupted. If no event interrupts the Wait and the time elapses, the run result is WaitCompleted. Conditions are supported, but only the "Equals" operator is supported. "WaitCompleted" is always required operand, and every specified event is also required to be present as a condition operand.

## Errors

+ NoMatchingError - If no other Error matches.
+ ParticipantNotFound - The supported event currently is "BotParticipantDisconnected".

## Restrictions


This is supported in every type of flow, but is supported only by the chat channel. 

## Corresponding block in the UI


[Wait](https://docs.aws.amazon.com/connect/latest/adminguide/wait.html) 