<!-- Source: https://docs.squirro.com/en/latest/api/squirro.lib.nlp.steps.flow.ConditionStep.html -->
# ConditionStep

**`class ConditionStep(config)`**

Bases: [`BatchedStep`](../technical/libnlp/steps/standard.md#squirro.lib.nlp.steps.batched_step.BatchedStep)

Step that executes other steps based on provided condition.

Parameters

- `step` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – flow
- `type` ([`str`](https://docs.python.org/3.11/library/stdtypes.html#str)) – condition
- `condition` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)) – Condition based on which the step to be executed is
  selected. If declared condition passed, the step defined in the
  “true_step” key is executed, otherwise the step from the “false_step” key
  is chosen. Available conditions: healthy_service, healthy_nlp_service,
  truthy_server_config.
- `true_step` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)) – Step configuration that should be executed when condition is
  true.
- `false_step` ([`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)) – Step configuration that should be executed when condition is
  false.

**Example**

```json
{
    "step": "flow",
    "type": "condition",
    "condition": {
        "truthy_server_config": {
            "key": "topic.test-key"
        }
    },
    "true_step": {
        "step": "external",
        "type": "remote_spacy",
        "name": "remote_spacy",
        "field_mapping": {
            "user_terms_str": "nlp"
        },
        "disable_pipes__default": ["merge_noun_chunks"]
    },
    "false_step": {
        "step": "app",
        "type": "query_processing",
        "name": "custom_spacy_normalizer",
        "model_cache_expiration": 345600,
        "infix_split_hyphen": false,
        "infix_split_chars": ":<>=",
        "merge_noun_chunks": false,
        "merge_phrases": true,
        "merge_entities": true,
        "fallback_language": "en",
        "exclude_spacy_pipes": [],
        "spacy_model_mapping": {
            "en": "en_core_web_sm",
            "de": "de_core_news_sm"
        }
    }
}
```

Methods SummaryMethods Documentation

**`choose_step_config()`**

Return type

[`dict`](https://docs.python.org/3.11/library/stdtypes.html#dict)

**`is_condition_true(**kwargs)`**

**`process_batch(batch)`**

Process a batch of documents. If not defined will default to using
self.process_doc for each document in the batch.

Parameters

`batch` ([`list`](https://docs.python.org/3.11/library/stdtypes.html#list)`(`[`Document`](../technical/libnlp/base.md#squirro.lib.nlp.document.Document)`)`) – List of documents

Returns

List of processed documents

Return type

[list](https://docs.python.org/3.11/library/stdtypes.html#list)([Document](../technical/libnlp/base.md#squirro.lib.nlp.document.Document))
