Skip to content

Updated CLI walkthrough for setting up with Facebook#8

Merged
jreakin merged 2 commits intomainfrom
facebook-cli-setup-enhancement
Jan 30, 2026
Merged

Updated CLI walkthrough for setting up with Facebook#8
jreakin merged 2 commits intomainfrom
facebook-cli-setup-enhancement

Conversation

@jreakin
Copy link
Member

@jreakin jreakin commented Jan 29, 2026

TL;DR

Enhanced Facebook setup experience with improved credential validation, detailed help guides, and better error handling.

What changed?

  • Added FACEBOOK_SETUP_QUICK.md quick reference guide for Facebook setup
  • Improved credential validation for Facebook Page ID, Access Token, and Verify Token
  • Added interactive help dialogs (type ? for detailed instructions)
  • Added webhook configuration info saved to WEBHOOK_INFO.txt
  • Enhanced setup flow with confirmation steps and better error messages
  • Improved post-setup instructions with clearer next steps
  • Added validation tests for Facebook credential formats

How to test?

  1. Run the setup CLI:
    uv run python -m src.cli.setup_cli setup
  2. Test the credential validation by entering invalid formats
  3. Try the help system by typing ? at any credential prompt
  4. Complete the setup and verify WEBHOOK_INFO.txt is created
  5. Run the unit tests:
    pytest tests/unit/test_setup_cli.py

Why make this change?

Users were struggling with Facebook setup, particularly finding and entering the correct credentials. This change makes the process more user-friendly by:

  1. Providing clear guidance on where to find each credential
  2. Validating input formats to catch common mistakes early
  3. Offering detailed help when needed
  4. Saving webhook configuration for easy reference
  5. Improving the overall setup experience with better feedback and instructions

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Warning

Rate limit exceeded

@jreakin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch facebook-cli-setup-enhancement

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member Author

jreakin commented Jan 29, 2026

@sentry
Copy link

sentry bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 96.47059% with 6 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/cli/setup_cli.py 96.47% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the Facebook setup CLI experience by adding comprehensive credential validation, interactive help dialogs, and improved documentation. The changes aim to reduce user errors during the Facebook bot setup process.

Changes:

  • Added credential validation for Facebook Page ID, Access Token, and Verify Token with format checking
  • Implemented interactive help system (type ? at prompts for detailed instructions)
  • Created FACEBOOK_SETUP_QUICK.md quick reference guide
  • Added webhook configuration file generation (WEBHOOK_INFO.txt) for easy reference
  • Enhanced user feedback with confirmation prompts and better error messages

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 14 comments.

File Description
src/cli/setup_cli.py Added validation functions, interactive help system, confirmation prompts, and webhook info file generation
tests/unit/test_setup_cli.py Updated mocks for new confirmation prompts and added comprehensive validation function tests
docs/FACEBOOK_SETUP_QUICK.md New quick reference guide for Facebook setup process
.gitignore Added WEBHOOK_INFO.txt to prevent sensitive webhook configuration from being committed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +625 to +629
VALID_VERIFY_TOKEN,
]
setup()

webhook_file = tmp_path / "WEBHOOK_INFO.txt"
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The validation accepts 15-17 digit Page IDs, but the tests only verify 15 and 17 digits. Consider adding a test case for 16 digits to ensure complete coverage of the regex range {15,17}.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +95
def _prompt_with_validation(
message: str,
validator: Callable[[str], bool],
error_message: str,
hide_input: bool = False,
max_attempts: int = 3,
) -> str:
"""Prompt user with input validation."""
for attempt in range(max_attempts):
value = typer.prompt(message, hide_input=hide_input).strip()
if validator(value):
return value
typer.echo(
typer.style(f"❌ {error_message}", fg=typer.colors.RED),
err=True,
)
if attempt < max_attempts - 1:
typer.echo(f" {max_attempts - attempt - 1} attempts remaining\n")
else:
typer.echo("❌ Maximum attempts reached. Exiting.")
raise typer.Exit(1)
return value # unreachable but satisfies type checker


Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The _prompt_with_validation function is defined but never used in the codebase. It appears to be superseded by _prompt_with_help. Consider removing this dead code to improve maintainability.

Suggested change
def _prompt_with_validation(
message: str,
validator: Callable[[str], bool],
error_message: str,
hide_input: bool = False,
max_attempts: int = 3,
) -> str:
"""Prompt user with input validation."""
for attempt in range(max_attempts):
value = typer.prompt(message, hide_input=hide_input).strip()
if validator(value):
return value
typer.echo(
typer.style(f"❌ {error_message}", fg=typer.colors.RED),
err=True,
)
if attempt < max_attempts - 1:
typer.echo(f" {max_attempts - attempt - 1} attempts remaining\n")
else:
typer.echo("❌ Maximum attempts reached. Exiting.")
raise typer.Exit(1)
return value # unreachable but satisfies type checker

Copilot uses AI. Check for mistakes.
typer.echo(" Option 1: Use the default we generate for you")
typer.echo(" Option 2: Type your own (e.g., 'my-bot-token-2024')")
typer.echo(" Option 3: Generate random in terminal:")
typer.echo(" openssl rand -base64 32")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The documentation suggests using openssl rand -base64 32 to generate a verify token, but this command produces base64-encoded strings containing /, +, and = characters, which will fail the validation regex that only allows [a-zA-Z0-9_-].

Consider changing the suggestion to:

  • openssl rand -hex 16 (produces 32 hex characters)
  • Or document that base64 output needs to be sanitized
Suggested change
typer.echo(" openssl rand -base64 32")
typer.echo(" openssl rand -hex 16 # 32 hex chars, regex-safe")

Copilot uses AI. Check for mistakes.
) -> str:
"""Prompt with optional help dialog (type '?' for detailed help)."""
if credential_type == "page_id":
typer.echo("💡 Tip: Page ID is a 15-digit number")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Inconsistency: The tip says "Page ID is a 15-digit number" but the validation regex ^\d{15,17}$ accepts 15-17 digits. While this may be intentional to handle different Facebook Page ID formats, the documentation should clarify that Page IDs can be 15-17 digits to avoid user confusion.

Suggested change
typer.echo("💡 Tip: Page ID is a 15-digit number")
typer.echo("💡 Tip: Page ID is a 15–17 digit number")

Copilot uses AI. Check for mistakes.
typer.echo(" Format: EAAA... (very long)")
typer.echo("")
typer.echo(" 3. Verify Token: Any string you create (save it!)")
typer.echo(" Tip: Use 'openssl rand -base64 32' to generate")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Same suggestion issue as in the help dialog: openssl rand -base64 32 produces characters that will fail validation. Consider suggesting openssl rand -hex 16 instead, which produces 32 alphanumeric characters that will pass validation.

Suggested change
typer.echo(" Tip: Use 'openssl rand -base64 32' to generate")
typer.echo(" Tip: Use 'openssl rand -hex 16' to generate")

Copilot uses AI. Check for mistakes.
def _validate_verify_token(token: str) -> bool:
"""Validate verify token format."""
token = token.strip()
return bool(re.match(r"^[a-zA-Z0-9_-]{8,100}$", token))
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The suggested command openssl rand -base64 32 will generate tokens containing characters like /, +, and = that are not allowed by the validation regex ^[a-zA-Z0-9_-]{8,100}$. This will cause user confusion when they follow the documentation but their token is rejected.

Consider either:

  1. Updating the validation regex to accept base64 characters: ^[a-zA-Z0-9_+/=-]{8,100}$
  2. Changing the suggestion to use a URL-safe base64 variant: openssl rand -base64 32 | tr '+/' '-_' | tr -d '='
  3. Changing the suggestion to use hex encoding: openssl rand -hex 16
Suggested change
return bool(re.match(r"^[a-zA-Z0-9_-]{8,100}$", token))
return bool(re.match(r"^[a-zA-Z0-9_+/=-]{8,100}$", token))

Copilot uses AI. Check for mistakes.
typer.echo("")
typer.echo("📌 Quick Reference:")
typer.echo(" 1. Page ID: Find in Messenger Settings → Access Tokens dropdown")
typer.echo(" Format: 123456789012345 (15 digits)")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Same inconsistency: The message says "15 digits" but the validation accepts 15-17 digits. Consider updating to say "15-17 digits" to match the actual validation.

Copilot uses AI. Check for mistakes.
).hexdigest()[:12]

page_id = _prompt_with_help(
"🎯 Facebook Page ID (15-digit number)",
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The prompt message says "15-digit number" but the validation accepts 15-17 digits. This inconsistency appears throughout the code. Consider updating to "(15-17 digit number)" to match the actual validation and accommodate different Facebook Page ID formats.

Copilot uses AI. Check for mistakes.

### 5. Create Verify Token (1 min)

- Use: `openssl rand -base64 32`
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The suggested command openssl rand -base64 32 will generate tokens with /, +, and = characters that fail the validation regex in setup_cli.py which only accepts [a-zA-Z0-9_-]. Consider changing to openssl rand -hex 16 which produces 32 hex characters that will pass validation.

Suggested change
- Use: `openssl rand -base64 32`
- Use: `openssl rand -hex 16`

Copilot uses AI. Check for mistakes.
Paste when prompted:

- Website URL
- Page ID (15 digits)
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The documentation says "Page ID (15 digits)" but the validation accepts 15-17 digits. For consistency, update to "(15-17 digits)" to match the actual validation.

Suggested change
- Page ID (15 digits)
- Page ID (15-17 digits)

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Member Author

jreakin commented Jan 29, 2026

Merge activity

  • Jan 29, 11:55 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 30, 12:09 AM UTC: Graphite rebased this pull request as part of a merge.
  • Jan 30, 12:10 AM UTC: @jreakin merged this pull request with Graphite.

@jreakin jreakin changed the base branch from facebook-user-input-addition to graphite-base/8 January 30, 2026 00:07
@jreakin jreakin changed the base branch from graphite-base/8 to main January 30, 2026 00:08
@jreakin jreakin force-pushed the facebook-cli-setup-enhancement branch from 99fa9c2 to 7c155a8 Compare January 30, 2026 00:09
@jreakin jreakin merged commit 85da92c into main Jan 30, 2026
6 checks passed
@jreakin jreakin deleted the facebook-cli-setup-enhancement branch January 30, 2026 00:19
@notion-workspace
Copy link

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.

2 participants