Skip to content

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.

Notifications You must be signed in to change notification settings

saleemh/pythonista-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📱 Notion Row Adder for Pythonista

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.

🎯 What This Does

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.

📱 Quick Start

Option 1: Use the Runner Script (Recommended for Testing)

  1. Open Pythonista on your iPhone/iPad
  2. Run run-row-adder.py - This will execute with pre-configured example data
  3. Check your results - The script will attempt to add "best Indian restaurant in Paris" to a "Paris Attractions" database

Option 2: Run the Main Script Directly

  1. Open Pythonista
  2. Run add-new-row-mobile.py
  3. 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")

⚙️ Initial Setup Required

Before first use, you need to configure your API keys:

1. Get API Keys

2. Configure API Keys in Pythonista

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"
}

3. Set Up Custom Prompts

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"

🔧 Configuration Functions

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

📝 How to Customize

Modify the Runner Script

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
]

Examples:

# 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"]

📋 Requirements

  • 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)

🎯 Database Setup

  1. Create or identify your Notion database
  2. Share the database with your Notion integration
  3. Note the exact database name (case-sensitive)
  4. Identify the key property (usually "Name", "Title", etc.)
  5. Create a custom OpenAI prompt for your database structure

🚨 Troubleshooting

  • "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

📖 Detailed Setup Guide

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

🔐 Security Notes

  • 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

🎉 Example Workflow

  1. Think of something to add: "Italian restaurant in Rome with great pasta"
  2. Run the script with your database name and that description
  3. AI processes the text and generates structured data
  4. Script automatically adds/updates the entry in your Notion database
  5. Check Notion to see your new row!

Perfect for quickly capturing information on the go and having it automatically organized in your Notion workspace.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages