# Interactive DevOps workflows in your terminal

> Flowpipe's input step now works in your terminal, as well as via Slack, MSTeams, and email.

By Turbot Team
Published: 2024-07-24


  Flowpipe supports workflows that require decisions based on human input. As detailed in our blog posts [Workflow for DevOps: Approvals and inputs to engage your team](https://flowpipe.io/blog/human-interaction) and [Control AWS costs with 29 FinOps workflows](https://flowpipe.io/blog/finops-workflows-for-aws), pipelines can push that decision-making to Slack, MSTeams, or email. Now, these interactions can happen directly in your terminal too.

  ## Decisions in your terminal

Here's an example: a pipeline called `check_old_branches` that asks whether to delete stale branches in a repository.

```
$ flowpipe pipeline run check_old_branches
┃ Do you want to delete branch add-tables?
┃ > Skip
┃   Delete
```

Flowpipe pauses for a decision. Let's skip this one, and proceed.

```
┃ Do you want to delete branch update-slack-community-link?
┃   Skip
┃ > Delete
```

Here we'll choose Delete.

If those are the only two branches matching a Steampipe query that finds stale branches, Flowpipe concludes with this report.

```
Skipped branch add-tables
Deleted branch update-slack-community-link
```

## How it works

To look for branches older than 30 days that also lack pull requests, the pipeline runs a [query step](https://flowpipe.io/docs/flowpipe-hcl/step/query) that joins two Steampipe tables: [github_branch](https://hub.steampipe.io/plugins/turbot/github/tables/github_branch) and [github_pull_request](https://hub.steampipe.io/plugins/turbot/github/tables/github_pull_request).

Here's the pipeline that `check_old_branches` calls to make a decision for each branch. It receives a branch name from the query step, prompts to `Skip` or `Delete`, then calls the `skip_branch` or `delete_branch` pipelines accordingly.

```hcl
pipeline "handle_one_branch" {
  param "name" {
    type        = string
    description = "The name of the branch."
  }

  step "input" "approve_deletion" {
    type     = "button"
    prompt   = "Do you want to delete branch ${param.name}?"
    notifier = notifier.default
    option "Skip" {}
    option "Delete" {}
  }

  step "pipeline" "delete_branch" {
    pipeline = pipeline.delete_branch
    args = {
      name = param.name
    }
    if = step.input.approve_deletion.value == "Delete"
  }

  step "pipeline" "skip_branch" {
    pipeline = pipeline.skip_branch
    args = {
      name = param.name
    }
    if = step.input.approve_deletion.value == "Skip"
  }
}
```

To run a pipeline like this, you'd first install the [GitHub mod for Flowpipe](https://hub.flowpipe.io/mods/turbot/github) to gain access to the [delete_branch](https://hub.flowpipe.io/mods/turbot/github/pipelines/github.pipeline.delete_branch) pipeline.

## Develop in the terminal, then interact with your team

The example uses the default [notifier](https://flowpipe.io/docs/reference/config-files/notifier) to interact in the terminal, versus alternate notifiers that you might configure for [Slack](https://flowpipe.io/docs/reference/config-files/integration/slack), [MSTeams](https://flowpipe.io/docs/reference/config-files/integration/msteams), or [email](https://flowpipe.io/docs/reference/config-files/integration/email). If you're the decision-maker, you can handle approval-based workflows directly. When other team members need to approve, you can route decisions to them using their preferred communication channels. 

And of course you can tap into two powerful ecosystems: Steampipe's [suite of API plugins](https://hub.steampipe.io), and Flowpipe's [collection of utility pipelines](https://hub.flowpipe.io).

Give this new feature a try, and [let us know](https://turbot.com/community/join) how it enhances your workflow automation!
