---
title: "Contact Human Command"
description: "Send messages to humans and wait for responses"
---

# npx humanlayer contact_human

The `contact_human` command allows you to send a message to a human through your configured contact channels (Slack, email) and wait for their response. This is useful for getting human input, approvals, or feedback directly from the command line.

## Usage

```bash
npx humanlayer contact_human <message> [options]
```

## Arguments

| Argument    | Description                                                  | Required |
| ----------- | ------------------------------------------------------------ | -------- |
| `<message>` | The message to send to the human. Use `-` to read from stdin | Yes      |

## Options

### General Options

| Flag                   | Description         | Default                                |
| ---------------------- | ------------------- | -------------------------------------- |
| `--config-file <path>` | Path to config file | `~/.config/humanlayer/humanlayer.json` |

### Slack Options

| Flag                        | Description                          | Default |
| --------------------------- | ------------------------------------ | ------- |
| `--slack-channel <id>`      | Slack channel or user ID             | -       |
| `--slack-bot-token <token>` | Slack bot token                      | -       |
| `--slack-context <context>` | Context about the Slack channel/user | -       |
| `--slack-thread-ts <ts>`    | Slack thread timestamp               | -       |
| `--slack-blocks [boolean]`  | Use experimental Slack blocks        | `true`  |

### Email Options

| Flag                        | Description                       | Default |
| --------------------------- | --------------------------------- | ------- |
| `--email-address <email>`   | Email address to contact          | -       |
| `--email-context <context>` | Context about the email recipient | -       |

## Examples

### Basic Usage

```bash
npx humanlayer contact_human "Should we proceed with the deployment?"
```

### Reading from Stdin

```bash
echo "Review this code change" | npx humanlayer contact_human -
```

### With Slack Configuration

```bash
npx humanlayer contact_human "Approve marketing campaign" \
  --slack-channel C123456789 \
  --slack-context "marketing team"
```

### With Email Configuration

```bash
npx humanlayer contact_human "Need approval for budget increase" \
  --email-address manager@company.com \
  --email-context "Finance Manager"
```

### Using Environment Variables

```bash
export HUMANLAYER_SLACK_CHANNEL=C123456789
export HUMANLAYER_SLACK_BOT_TOKEN=xoxb-your-bot-token
npx humanlayer contact_human "Quick question about the project"
```

## Interactive Flow

```bash
$ npx humanlayer contact_human "Should we deploy to production?"
Contacting human...
Human response received
Yes, proceed with the deployment. Make sure to monitor the metrics closely.
```

## Input Methods

### Direct Message

Pass the message directly as an argument:

```bash
npx humanlayer contact_human "Your message here"
```

### From Stdin

Use `-` to read the message from stdin, useful for piping:

```bash
cat message.txt | npx humanlayer contact_human -
echo "Dynamic message" | npx humanlayer contact_human -
```

## Configuration

### Required Configuration

You must configure at least one contact channel:

**Slack Channel:**

- Channel/User ID: `--slack-channel` or `HUMANLAYER_SLACK_CHANNEL`
- Bot Token: `--slack-bot-token` or `HUMANLAYER_SLACK_BOT_TOKEN`

**Email:**

- Email Address: `--email-address` or `HUMANLAYER_EMAIL_ADDRESS`

### Optional Configuration

- Context about recipient: `--slack-context` / `--email-context`
- Slack thread: `--slack-thread-ts`
- Slack blocks: `--slack-blocks`

## Response Handling

The command will:

1. Send your message through the configured channel
2. Wait for a human response
3. Output the response to stdout
4. Exit with code 0 on success

Error messages are sent to stderr, so you can capture just the human response:

```bash
response=$(npx humanlayer contact_human "Question?" 2>/dev/null)
echo "Human said: $response"
```

## Error Handling

### No Contact Channel Configured

```bash
$ npx humanlayer contact_human "test"
Error: No contact channel configured. Please specify --slack-channel, --email-address, or use environment variables/config file.
```

### Invalid Configuration

The command will validate your configuration and provide helpful error messages for:

- Missing API tokens
- Invalid channel IDs
- Network connectivity issues

## Integration Examples

### In Shell Scripts

```bash
#!/bin/bash
if npx humanlayer contact_human "Deploy to production?" 2>/dev/null | grep -i "yes"; then
    echo "Deployment approved, proceeding..."
    ./deploy.sh
else
    echo "Deployment not approved"
    exit 1
fi
```

### With Git Hooks

```bash
# Pre-push hook
if [ "$remote_url" = "production" ]; then
    response=$(npx humanlayer contact_human "Push to production?" 2>/dev/null)
    if ! echo "$response" | grep -i "yes"; then
        echo "Push cancelled by human"
        exit 1
    fi
fi
```

## Best Practices

1. **Clear messages**: Be specific about what you're asking
2. **Provide context**: Use `--slack-context` or `--email-context` to help humans understand
3. **Error handling**: Always check the exit code and handle failures
4. **Timeouts**: Be aware that humans may take time to respond
5. **Automation**: Use environment variables or config files for repeated usage
