A Python script designed for iPhone/iPad that uses AI to intelligently add rows to your Notion databases. Simply describe what you want to add in natural language, and the script will generate structured data and update your Notion database.
This script takes natural language input (like "best Indian restaurant in Paris") and uses OpenAI's API to generate structured JSON data that gets added to your Notion database. It can either create new entries or update existing ones based on a key property.
- Open Pythonista on your iPhone/iPad
- Run
run-row-adder.py
- This will execute with pre-configured example data - Check your results - The script will attempt to add "best Indian restaurant in Paris" to a "Paris Attractions" database
- Open Pythonista
- Run
add-new-row-mobile.py
- Follow the interactive prompts:
- Database name (e.g., "Paris Attractions")
- Key property (e.g., "Attraction")
- Your input text (e.g., "best Indian restaurant in Paris")
Before first use, you need to configure your API keys:
- Notion Integration Token: Get from https://notion.so/my-integrations
- OpenAI API Key: Get from https://platform.openai.com/api-keys
Edit the sensitive.py
file (or create it) with your configuration:
MOBILE_CONFIG = {
"NOTION_KEY": "secret_your_notion_integration_token",
"OPENAI_API_KEY": "sk-your_openai_api_key",
"OPENAI_ENDPOINT": "https://api.openai.com/v1/responses"
}
For each database, you need to create custom prompts in OpenAI and set environment variables:
# Add to MOBILE_CONFIG for each database
"PARIS_ATTRACTIONS_PROMPT_ID": "your_prompt_id",
"PARIS_ATTRACTIONS_PROMPT_VERSION": "your_prompt_version"
The script includes helpful setup and testing functions:
# Run these in Pythonista console:
interactive_setup() # Interactive API key setup
test_configuration() # Test your API connections
Edit run-row-adder.py
to change the parameters:
sys.argv = [
"add-new-row-mobile.py",
"YOUR_DATABASE_NAME", # Replace with your database name
"YOUR_KEY_PROPERTY", # Replace with your key property
"YOUR_INPUT_TEXT" # Replace with what you want to add
]
# For a movie database
sys.argv = ["add-new-row-mobile.py", "My Movies", "Title", "Inception - mind-bending sci-fi thriller"]
# For a restaurant database
sys.argv = ["add-new-row-mobile.py", "Restaurants", "Name", "Joe's Pizza - best pizza in NYC"]
# For a book database
sys.argv = ["add-new-row-mobile.py", "Reading List", "Book", "The Hobbit by Tolkien - fantasy adventure"]
- Pythonista 3 installed on iPhone/iPad
- Active internet connection
- Notion account with integration set up
- OpenAI API account with custom prompts configured
- Required Python packages:
requests
(usually pre-installed in Pythonista)
- Create or identify your Notion database
- Share the database with your Notion integration
- Note the exact database name (case-sensitive)
- Identify the key property (usually "Name", "Title", etc.)
- Create a custom OpenAI prompt for your database structure
- "Database not found": Check exact spelling and integration permissions
- "API key errors": Verify keys in
sensitive.py
configuration - "Custom prompt not found": Check prompt ID and version in configuration
- Network errors: Verify internet connection and API endpoints
For comprehensive setup instructions, see archive/MOBILE_SETUP_GUIDE.md
which includes:
- Step-by-step Pythonista installation
- Detailed API key setup
- Notion integration configuration
- OpenAI prompt creation
- Advanced troubleshooting
- Never commit API keys to version control
- Store sensitive configuration in
sensitive.py
(add to.gitignore
) - Monitor your OpenAI API usage for unexpected charges
- Keep your Notion integration permissions minimal
- Think of something to add: "Italian restaurant in Rome with great pasta"
- Run the script with your database name and that description
- AI processes the text and generates structured data
- Script automatically adds/updates the entry in your Notion database
- Check Notion to see your new row!
Perfect for quickly capturing information on the go and having it automatically organized in your Notion workspace.