CLI
Contact Human Command
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
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
Reading from Stdin
With Slack Configuration
With Email Configuration
Using Environment Variables
Interactive Flow
Input Methods
Direct Message
Pass the message directly as an argument:
From Stdin
Use -
to read the message from stdin, useful for piping:
Configuration
Required Configuration
You must configure at least one contact channel:
Slack Channel:
- Channel/User ID:
--slack-channel
orHUMANLAYER_SLACK_CHANNEL
- Bot Token:
--slack-bot-token
orHUMANLAYER_SLACK_BOT_TOKEN
Email:
- Email Address:
--email-address
orHUMANLAYER_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:
- Send your message through the configured channel
- Wait for a human response
- Output the response to stdout
- Exit with code 0 on success
Error messages are sent to stderr, so you can capture just the human response:
Error Handling
No Contact Channel Configured
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
With Git Hooks
Best Practices
- Clear messages: Be specific about what you’re asking
- Provide context: Use
--slack-context
or--email-context
to help humans understand - Error handling: Always check the exit code and handle failures
- Timeouts: Be aware that humans may take time to respond
- Automation: Use environment variables or config files for repeated usage