This system provides an automated address lookup service, integrating database queries, natural language processing, and communication APIs to deliver detailed property information and manage user interactions.
This API provides various endpoints for managing conversations, broadcasts, and data lookups. It's built using Flask and integrates with services like Missive and Twilio.
- Address search and validation
- Property information retrieval (ownership, tax status, rental status)
- Conversation tracking and summarization
Purpose: Searches for property information based on a given address.
Request Body:
conversation: Object containing conversation details.message: Object containing message details, including the address to search.
Response: Returns property information if found, or appropriate error messages.
Purpose: Confirms and processes a property lookup based on the latest address in a conversation.
Request Body:
conversation: Object containing conversation details.message: Object containing message details.
Response: Returns success message or error details.
Purpose: Retrieves additional information about a property, including tax and rental status.
Request Body:
conversation: Object containing conversation details.message: Object containing message details.
Response: Returns additional property information or error details.
Purpose: Initiates a background job to fetch property data.
Response: Returns a message indicating that the data fetch has started.
Purpose: Initiates a background job to fetch rental data.
Response: Returns a message indicating that the data fetch has started.
Purpose: Generates and sends a weekly analytics report.
Response: Returns a message confirming that the weekly report was sent.
Purpose: Retrieves detailed information about a specific conversation.
Query Parameters:
reference: Phone number reference for the conversation.
Response: Returns conversation data including assignees, labels, and summaries.
Purpose: Updates contact information for a given phone number.
Request Body:
email: (optional) New email address for the contact.zipcode: (optional) New zipcode for the contact.
Response: Returns a success message or error details.
Our application uses a PostgreSQL database with the following main tables:
Stores detailed property information for Wayne County, Detroit. It includes:
- Geographic data (wkb_geometry)
- Parcel information (parcelnumb, tax_id)
- Property details (zoning, structure info, value)
- Owner information
- Address details
- Tax information
Contains information about registered rental properties:
- Geographic data (wkb_geometry)
- Registration details (record_id, date_status)
- Address information
Tracks the history of address lookups:
- Address
- Zip code
- Tax status
- Rental status
Stores templates for lookup responses:
- Template name
- Content
- Type
Stores weekly analytics data:
- Conversation metrics
- User satisfaction metrics
- Property status counts
- Reply and unsubscribe statistics by user segment
Stores information about message authors:
- Phone number (primary key)
- Name
- Unsubscribe status
- Zipcode
Records details of messages sent via Twilio:
- Message preview
- Delivery information
- References to other messages
- Broadcast reply status
Links conversations to labels:
- Conversation ID
- Label ID
- Update timestamp
- Archive status
Tracks the assignment and status of conversations:
- Various status flags (unassigned, closed, archived, etc.)
- Conversation ID
- User ID of assignee
Stores user information:
- User ID (UUID)
- Name
- Avatar URL
Stores comments and tasks related to conversations:
- Comment body
- Creation and completion timestamps
- Associated user and conversation
- Task status
SUPABASE_SERVICE_ROLE_KEY: A secret key used for Supabase service role access, granting full database access.JWT_SECRET: A secret key used to sign and verify JSON Web Tokens for authentication.HMAC_SECRET: A secret key used for HMAC (Hash-based Message Authentication Code) operations.DATABASE_URL: The connection string for your database.OPENAI_API_KEY: Your API key for accessing OpenAI services.PHONE_NUMBER: A phone number, possibly for SMS notifications or verification.SUPABASE_ID: The unique identifier for your Supabase project.API_KEY: A secret key from SupbaseMISSIVE_SECRET: A secret key for authenticating with the Missive API.MISSIVE_ORGANIZATION: The organization identifier for your Missive account.MISSIVE_WEEKLY_REPORT_CONVERSATION_ID: The ID of a specific conversation in Missive for weekly reports.SFTP_HOST: The hostname or IP address of the SFTP server(Detroit rental property data)SFTP_USERNAME: The username for authenticating with the SFTP server.SFTP_PASSWORD: The password for authenticating with the SFTP server.BACKEND_URL: The URL of your backend server.SUMMARY_CONVO_SIDEBAR_ADDRESS: Possibly an address or endpoint for a conversation summary sidebar feature.
graph TD
A[Webhook call to api/address lookup] --> B[process address information]
B --> C[Construct a prompt address information query]
C --> D[Llama index query engine is called to handle the address query]
D --> M{Address status?}
M -- Correct --> N[Proceed with handle_match]
M -- Wrong --> O[Handle no_match]
M -- Ambiguous --> E[Execute handle_ambiguous]
E --> I[generate response uses chatGPT]
O --> I
N --> I
I --> K[Post missive response using sendMissiveResponse]
docker build -t lookup .
docker run -p 5000:5000 --name lookup_app --restart unless-stopped lookupThis is hosted with Docker Compose inside an EC2 instance. To access it:
ssh -i Outlier-aws-ec2-key.pem ubuntu@<ec2-host-ip-or-dns>
cd /home/ubuntu/outlier-experimentsFind the SSH key (Outlier-aws-ec2-key.pem) and other credentials in 1Password under txt-outlier-lookups.
- Python 3.x
- Docker (for containerized deployment)
- Supabase account (for pg_cron extension)
The script scripts/init_cron.py initializes cron jobs using the pg_cron extension of Supabase.
These cron jobs are scheduled to run at 00:00 on the first day of every month.
To initialize the cron jobs, run the following command:
python -m scripts.init_cron