|
| 1 | +<!-- Auto-synced from AGENTS.md — do not edit directly. --> |
| 2 | +# Phone Number Lookup |
| 3 | + |
| 4 | +A Twilio Serverless Function and web UI that lets you look up detailed intelligence about any phone number using the Twilio Lookup v2 API — including validation, line type, carrier, caller name, SMS pumping risk, SIM swap detection, and more. |
| 5 | + |
| 6 | +## Commands |
| 7 | + |
| 8 | +```bash |
| 9 | +# Initialize a new project from this template |
| 10 | +twilio serverless:init lookup-sample --template=lookup && cd lookup-sample |
| 11 | + |
| 12 | +# Install dependencies |
| 13 | +npm install |
| 14 | + |
| 15 | +# Run locally |
| 16 | +npm start |
| 17 | + |
| 18 | +# Open the UI |
| 19 | +# Visit http://localhost:3000/index.html in your browser |
| 20 | + |
| 21 | +# Deploy to Twilio |
| 22 | +twilio serverless:deploy |
| 23 | +``` |
| 24 | + |
| 25 | +## Environment Variables |
| 26 | + |
| 27 | +Copy `.env.example` to `.env`. Never commit `.env`. |
| 28 | + |
| 29 | +```bash |
| 30 | +cp .env.example .env |
| 31 | +``` |
| 32 | + |
| 33 | +| Variable | Where to find | Format | |
| 34 | +| -------- | ------------- | ------ | |
| 35 | +| `ACCOUNT_SID` | [Console](https://console.twilio.com) homepage | Starts with `AC` | |
| 36 | +| `AUTH_TOKEN` | Console homepage → click to reveal | 32-char string. Treat as a password. | |
| 37 | + |
| 38 | +## Project Structure |
| 39 | + |
| 40 | +- `functions/lookup.js` — Serverless Function handler; calls the Lookup v2 API and returns phone number intelligence as JSON |
| 41 | +- `assets/index.html` — Web UI; accepts a phone number and selected data packages, displays the JSON response |
| 42 | +- `tests/lookup.test.js` — Jest tests for the Function handler |
| 43 | + |
| 44 | +## Agent Boundaries |
| 45 | + |
| 46 | +**Always:** |
| 47 | +- Confirm `.env` is populated with `ACCOUNT_SID` and `AUTH_TOKEN` before starting the server |
| 48 | +- Remind the user that Validation and Formatting is free; all other data packages are billed per lookup |
| 49 | +- Note that SIM Swap, Call Forwarding, and Line Status require additional carrier approval before use |
| 50 | + |
| 51 | +**Never:** |
| 52 | +- Hardcode credentials in source files |
| 53 | +- Run the app with missing or placeholder credentials |
| 54 | + |
| 55 | +## Verify It's Working |
| 56 | + |
| 57 | +1. Start the server with `npm start` and open `http://localhost:3000/index.html` |
| 58 | +2. Enter any phone number, select one or more data packages, and click **Lookup** — you should see a JSON response with the number's validation status and the requested intelligence fields |
| 59 | + |
| 60 | +## Twilio Resources |
| 61 | + |
| 62 | +- [Twilio Console](https://console.twilio.com) — credentials and account management |
| 63 | +- [Lookup v2 API docs](https://www.twilio.com/docs/lookup/v2-api) |
| 64 | +- [Lookup data packages](https://www.twilio.com/docs/lookup/v2-api#data-packages) |
| 65 | +- [Twilio Serverless Toolkit](https://www.twilio.com/docs/labs/serverless-toolkit) |
0 commit comments