Skip to content

feat(sample): add band sample run command - #52

Open
michaela-band wants to merge 2 commits into
mainfrom
feat/sample-command
Open

michaela-band wants to merge 2 commits into
mainfrom
feat/sample-command

Conversation

@michaela-band

Copy link
Copy Markdown
Contributor

Summary

  • Adds band sample command group with list and run subcommands
  • band sample run <name> --language <lang> clones a sample app, wires up Bandwidth credentials from the active band profile, starts an ngrok tunnel, creates a voice application, writes a populated .env, installs dependencies, and launches the app — all from one command
  • Optional --call-to <number> flag automatically dials a number once the app is healthy
  • Initial catalog: live-assistant (python) and voice-gather (python, node, java)
  • Exports cmdutil.LoadRawCredentials for surfacing raw client credentials to external processes (e.g. writing .env files) without duplicating config/keychain logic

Motivation

New Bandwidth users on Build accounts currently have to manually clone sample repos, figure out which env vars to set, find their credentials across multiple dashboard pages, set up ngrok, and configure a voice application before they can run a single sample. This collapses that entire flow into one command.

Usage

band sample list

band sample run live-assistant \
  --language python \
  --openai-key sk-... \
  --transfer-to +19195551234 \
  --call-to +19195551234

Test plan

  • band sample list shows the catalog with supported languages
  • band sample run live-assistant --language python --openai-key <key> --transfer-to <num> clones repo, starts ngrok, creates voice app, installs deps, runs app
  • --call-to <num> automatically dials after the app health check passes
  • Re-running reuses the existing clone (git pull) and voice application
  • --language unsupported returns a clear error listing valid options
  • Unknown sample name returns a clear error with band sample list hint
  • band auth logout → band sample run returns a clear "not logged in" error

🤖 Generated with Claude Code

Adds a new `band sample` command group that downloads and runs Bandwidth
sample applications with credentials automatically sourced from the active
band profile — no manual env var setup required.

Commands:
  band sample list
  band sample run <name> --language <lang> [--call-to <number>]

The run command clones the sample repo to ~/.band/samples/<name>-<lang>/,
starts an ngrok tunnel, creates a Bandwidth voice application with the
tunnel URLs, writes a populated .env file, installs language dependencies,
and launches the app. Pass --call-to to automatically dial a number once
the app is healthy.

Supported samples (initial catalog):
  live-assistant  python   openai-live-websockets-python
  voice-gather    python, node, java

Also exports cmdutil.LoadRawCredentials so the sample command can surface
client ID, client secret, and account ID for .env file generation without
duplicating the config/keychain lookup logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@michaela-band
michaela-band requested review from a team as code owners September 25, 2026 18:27
@bwappsec

bwappsec commented Sep 25, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread cmd/sample/run.go
// ── ngrok ────────────────────────────────────────────────────────────────
ngrokPath, err := exec.LookPath("ngrok")
if err != nil {
return fmt.Errorf("ngrok not found — install it with: brew install ngrok/ngrok/ngrok")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("ngrok not found — install it with: brew install ngrok/ngrok/ngrok")
return fmt.Errorf("ngrok not found — install it with: brew install ngrok")

too many ngrok's?

Comment thread cmd/sample/run.go
Comment on lines +132 to +135
appID, err := ensureVoiceApp(ctx, dashClient, acctID, "band-sample-"+name,
publicURL+"/webhooks/bandwidth/voice/initiate",
publicURL+"/webhooks/bandwidth/voice/status",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need to double check that these URLs are the same across all sample apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants