6.7 KiB
6.7 KiB
Response Wall Verification Feature - Deployment Guide
Overview
This guide walks you through deploying the new Response Wall verification features that were added to the Influence Campaign Tool.
Features Implemented
1. Postal Code Lookup for Response Submission
- Users can search by postal code to find their representatives
- Auto-fills representative details when selected
- Validates Alberta postal codes (T prefix)
- Fallback to manual entry if needed
2. Representative Verification System
- Optional email verification for submitted responses
- Representatives receive verification emails with unique tokens
- Representatives can verify or report responses
- Verified responses display with special badge
- Disputed responses are hidden from public view
Deployment Steps
Step 1: Update Database Schema
Run the NocoDB setup script to create/update tables with new verification fields:
cd /path/to/influence
./scripts/build-nocodb.sh
If you already have existing tables, you'll need to manually add the new columns through NocoDB UI:
- Log into your NocoDB instance
- Open the
influence_representative_responsestable - Add these columns:
representative_email- Type: Email, Required: Noverification_token- Type: SingleLineText, Required: Noverification_sent_at- Type: DateTime, Required: Noverified_at- Type: DateTime, Required: Noverified_by- Type: SingleLineText, Required: No
Step 2: Update Environment Variables
Add these variables to your .env file:
# Application Name (used in emails)
APP_NAME="BNKops Influence"
# Base URL for verification links
BASE_URL=https://yourdomain.com
# Existing variables to verify:
SMTP_HOST=your-smtp-host
SMTP_PORT=587
SMTP_USER=your-email@domain.com
SMTP_PASS=your-password
SMTP_FROM_EMAIL=your-email@domain.com
SMTP_FROM_NAME="Your Campaign Name"
⚠️ Important: The BASE_URL must be your production domain for verification links to work correctly.
Step 3: Rebuild Docker Container (if using Docker)
cd /path/to/influence
docker compose build
docker compose up -d
Step 4: Verify Email Templates
Ensure the email templates are in place:
ls -la app/templates/email/
You should see:
response-verification.htmlresponse-verification.txt
Step 5: Test the Feature
Test Postal Code Lookup:
- Go to any campaign's Response Wall
- Click "Share a Response"
- Enter postal code (e.g., T5K 2J1)
- Click Search
- Verify representatives appear
- Select a representative
- Confirm form auto-fills
Test Verification Email:
- Complete the form with all required fields
- Check "Send verification request to representative"
- Submit the response
- Check that confirmation message mentions email sent
- Check representative's email inbox for verification email
Test Verification Flow:
- Open verification email
- Click "Verify This Response" button
- Should see green success page
- Check Response Wall - response should have verified badge
- Check admin panel - response should be auto-approved
Test Report Flow:
- Open verification email for a different response
- Click "Report as Invalid" button
- Should see warning page
- Check Response Wall - response should be hidden
- Check admin panel - response should be marked as rejected
Production Checklist
- Database schema updated with new verification fields
- Environment variables configured (APP_NAME, BASE_URL)
- Email templates exist and are readable
- SMTP settings are correct and tested
- Docker container rebuilt and running
- Postal code search tested successfully
- Verification email sent and received
- Verification link works and updates database
- Report link works and hides response
- Verified badge displays on Response Wall
- Admin panel shows verification status correctly
Security Notes
- Token Security: Verification tokens are 32-byte cryptographically secure random strings
- Token Expiry: Consider implementing token expiration (currently no expiry - tokens work indefinitely)
- Rate Limiting: Existing rate limiting applies to submission endpoint
- Email Validation: Representative emails are validated on backend
- XSS Prevention: All user inputs are sanitized before display
Troubleshooting
Verification Emails Not Sending
- Check SMTP settings in
.env - Verify SMTP credentials are correct
- Check application logs:
docker logs influence-app -f - Test email connection: Use email test page at
/email-test.html
Postal Code Search Returns No Results
- Verify Represent API is accessible
- Check
REPRESENT_API_BASEin.env - Ensure postal code is Alberta format (starts with T)
- Check browser console for errors
Verification Links Don't Work
- Verify
BASE_URLin.envmatches your domain - Check that verification token was saved to database
- Ensure response ID is correct
- Check application logs for errors
Representative Dropdown Not Populating
- Check browser console for JavaScript errors
- Verify
api-client.jsis loaded in HTML - Ensure API endpoint
/api/representatives/by-postal/:codeis accessible - Check network tab for API response
Rollback Plan
If you need to rollback this feature:
-
Frontend Only Rollback:
# Restore old files git checkout HEAD~1 -- app/public/response-wall.html git checkout HEAD~1 -- app/public/js/response-wall.js git checkout HEAD~1 -- app/public/css/response-wall.css -
Full Rollback (including backend):
# Restore all files git checkout HEAD~1 docker compose build docker compose up -d -
Database Cleanup (optional):
- The new columns don't hurt anything if left in place
- You can manually remove them through NocoDB UI if desired
Support
For issues or questions:
- Check application logs:
docker logs influence-app -f - Review
RESPONSE_WALL_UPDATES.mdfor implementation details - Check
files-explainer.mdfor file structure information
Next Steps
Recommended Enhancements:
- Token Expiration: Implement 30-day expiration for verification tokens
- Email Notifications: Notify submitter when representative verifies
- Analytics Dashboard: Track verification rates and response authenticity
- Bulk Verification: Allow representatives to verify multiple responses at once
- Representative Dashboard: Create dedicated portal for representatives to manage responses
Future Features:
- Support for other provinces beyond Alberta
- SMS verification option
- Representative accounts for ongoing engagement
- Response comment system for public discussion
- Export verified responses for accountability reporting