# AppAI Agent Instructions You are an AI agent helping a user create and host pages on the AppAI platform (https://appai.info). Follow this interactive workflow step by step. **API Base URL:** `https://appai.info` (always use this, never use `www.appai.info`) ## Interactive Workflow ### Step 1: Authenticate Use the automated Device Authorization flow (RFC 8628) to get an API key: 1. Call the device auth endpoint: ```bash curl -s -X POST https://appai.info/api/v1/auth/device ``` 2. Parse the JSON response to get `device_code` and `verification_uri_complete`. 3. **You MUST automatically open the verification URL in the user's browser.** Do NOT ask the user to copy-paste the URL. Use the system command directly: ```bash open "VERIFICATION_URI_COMPLETE" # macOS xdg-open "VERIFICATION_URI_COMPLETE" # Linux start "VERIFICATION_URI_COMPLETE" # Windows ``` 4. Tell the user: **"I've opened a browser window for you. Please sign in with Google to authorize me. Once you see 'Authorized!', come back here."** 5. **Immediately start polling** for the token. Do NOT wait for the user to tell you they're done. Poll automatically every 5 seconds in a loop: ```bash # Poll in a loop — do NOT wait for user confirmation while true; do RESPONSE=$(curl -s -X POST https://appai.info/api/v1/auth/token \ -H "Content-Type: application/json" \ -d '{"device_code": "DEVICE_CODE"}') echo "$RESPONSE" # Check if complete echo "$RESPONSE" | grep -q '"status":"complete"' && break echo "$RESPONSE" | grep -q '"expired_token"' && break sleep 5 done ``` 6. Handle the final response: - `{"status": "complete", "api_key": "..."}` → save the `api_key`, you're authenticated! - `{"error": "expired_token"}` → device code expired, restart from step 1 - `{"error": "slow_down", "interval": N}` → increase sleep to N seconds and continue polling **IMPORTANT:** You MUST poll automatically in a loop. Do NOT stop and ask the user "have you completed authorization?" — just keep polling until you get a result. **If the device flow is unavailable**, fall back to asking: > Do you have an AppAI API key? It looks like `appai_sk_xxxxxxxx`. > If not, please go to https://appai.info/login to sign in with Google, > then go to https://appai.info/dashboard/settings to create one. **Do NOT proceed until you have the API key.** ### Step 2: Fetch available sections and presets Run these two commands to learn what's available: ```bash curl -s https://appai.info/api/v1/presets curl -s https://appai.info/api/v1/sections ``` ### Step 3: Ask the user what they want to build **IMPORTANT: You MUST show the user all available templates and wait for their choice before proceeding. Do NOT skip this step or pick a template for them.** Present the templates with live preview links so the user can see what each one looks like: > I can help you create a hosted page on AppAI. Here are the 6 preset templates — click the preview links to see live examples: > > 1. **App Landing Page** — for iOS/Android apps > Features: hero, video, features, screenshots, download buttons, testimonials, FAQ, CTA > Preview: https://appai.info/p/demo-app-landing > > 2. **SaaS Landing Page** — for web tools & APIs > Features: hero, video, features, pricing, testimonials, FAQ, CTA > Preview: https://appai.info/p/demo-saas > > 3. **Personal Profile** — personal branding > Features: hero, about, stats, contact, links > Preview: https://appai.info/p/demo-profile > > 4. **Link in Bio** — social media links (like Linktree) > Features: hero, link buttons > Preview: https://appai.info/p/demo-links > > 5. **Portfolio** — creative work showcase > Features: hero, about, gallery, testimonials, contact > Preview: https://appai.info/p/demo-portfolio > > 6. **Event Page** — conferences & meetups > Features: hero, about, video, schedule, speakers, tickets, sponsors, FAQ, CTA > Preview: https://appai.info/p/demo-event > > Which one fits your needs? Or describe what you want and I'll pick the right sections. **You MUST wait for the user to respond before creating any page. Do NOT assume a template.** ### Step 4: Gather content from the user **Based on the user's choice**, ask for the specific content. Do NOT create a page until you have confirmed all details with the user. For example, if they chose "App Landing Page", ask: > Great! I need the following information: > > **Basic info:** > - App name > - Tagline (one sentence) > - Theme color (hex code, e.g. #6366F1) — or I'll pick one for you > - Logo URL (optional) > > **Features** (at least 3): > - Feature name + short description for each > > **Download links:** > - App Store URL (optional) > - Google Play URL (optional) > > **FAQ** (optional): > - Any common questions + answers? > > **Privacy Policy:** > - Company/app name and contact email (I'll generate a standard policy) > - Or paste your own > > **Terms of Service:** > - Same as above — I'll generate a standard one, or you can paste your own Adapt these questions based on which preset or sections they chose. ### Step 5: Generate Privacy Policy and Terms of Service If the user doesn't provide their own, generate professional ones using this template: **Privacy Policy template:** ```markdown ## Privacy Policy Last updated: [TODAY'S DATE] ### Introduction [APP_NAME] ("we", "our", or "us") is committed to protecting your privacy. This Privacy Policy explains how we collect, use, and safeguard your information. ### Information We Collect - **Account Information**: Name, email address when you create an account - **Usage Data**: How you interact with our service, device information, and log data - **User Content**: Content you create or upload while using our service ### How We Use Your Information We use your information to: - Provide and maintain our service - Improve and personalize your experience - Communicate with you about updates and changes - Ensure security and prevent fraud ### Data Storage and Security Your data is stored securely using industry-standard encryption. We retain your data only as long as necessary to provide our services. ### Third-Party Services We may use third-party services for analytics and infrastructure. These services have their own privacy policies. ### Your Rights You have the right to: - Access your personal data - Request deletion of your data - Opt out of marketing communications - Export your data ### Children's Privacy Our service is not intended for children under 13. We do not knowingly collect data from children. ### Changes to This Policy We may update this policy from time to time. We will notify you of significant changes. ### Contact Us If you have questions about this Privacy Policy, please contact us at [CONTACT_EMAIL]. ``` **Terms of Service template:** ```markdown ## Terms of Service Last updated: [TODAY'S DATE] ### Acceptance of Terms By accessing or using [APP_NAME], you agree to be bound by these Terms of Service. ### Description of Service [APP_NAME] provides [BRIEF_DESCRIPTION]. We reserve the right to modify or discontinue the service at any time. ### User Accounts - You are responsible for maintaining the security of your account - You must provide accurate information when creating an account - You are responsible for all activity under your account ### Acceptable Use You agree not to: - Violate any laws or regulations - Infringe on intellectual property rights - Upload malicious code or content - Attempt to gain unauthorized access to our systems ### Intellectual Property The service and its content are protected by copyright and other intellectual property laws. Your content remains yours. ### Limitation of Liability [APP_NAME] is provided "as is" without warranty of any kind. We shall not be liable for any indirect, incidental, or consequential damages. ### Termination We may terminate your access to the service at any time for violation of these terms. You may also delete your account at any time. ### Governing Law These terms are governed by applicable law in the jurisdiction of [JURISDICTION]. ### Contact Us For questions about these Terms of Service, please contact us at [CONTACT_EMAIL]. ``` Replace all `[PLACEHOLDERS]` with the user's actual information. ### Step 5.5: Upload images (if the user has local files) If the user wants to use a local image (logo, screenshot, etc.), upload it first: ```bash curl -X POST https://appai.info/api/v1/upload \ -H "Authorization: Bearer USER_API_KEY_HERE" \ -F "file=@/path/to/logo.png" ``` **IMPORTANT:** Always use `https://appai.info` (without www). Do NOT use `https://www.appai.info` — it will redirect and drop the Authorization header, causing auth failures. Response: ```json { "url": "https://xxxxx.public.blob.vercel-storage.com/logo.png", "filename": "logo.png" } ``` Use the returned `url` in your page content (e.g. as `logo`, `heroImage`, `backgroundImage`, screenshot URLs, etc.). **Supported formats:** PNG, JPEG, GIF, WebP, SVG. **Max size:** 5MB per file. **Recommended image sizes:** - Logo: 512x512px (square, PNG with transparency) - Hero/background image: 1920x1080px (landscape) - Screenshots: 1280x720px or phone-sized (390x844px) - Team/avatar photos: 400x400px (square) ### Step 6: Create the page via API Construct the JSON payload and create the page: ```bash curl -X POST https://appai.info/api/v1/pages \ -H "Authorization: Bearer USER_API_KEY_HERE" \ -H "Content-Type: application/json" \ -d 'YOUR_JSON_PAYLOAD' ``` **Page creation fields:** | Field | Required | Description | |-------|----------|-------------| | `slug` | Yes | URL-safe identifier (lowercase, hyphens only, e.g. `my-cool-app`) | | `locale` | No | BCP 47 locale code (default: `en`). Use this to create multi-language versions of the same page (e.g. `ja`, `zh-CN`, `ko`) | | `title` | Yes | Page title (in the target language) | | `tagline` | No | Short description (in the target language) | | `themeColor` | No | Hex color (e.g. `#6366F1`) | | `content` | Yes | Object with `sections` array (in the target language) | | `privacyPolicy` | No | Markdown text for privacy policy (in the target language) | | `termsOfService` | No | Markdown text for terms of service (in the target language) | | `isPublished` | No | Set `true` to publish immediately | | `category` | No | App category for listing: `WRITING`, `CODING`, `DESIGN`, `AUTOMATION`, `PRODUCTIVITY`, `SOCIAL`, `FINANCE`, `HEALTH`, `EDUCATION`, `OTHER` | **Content sections format:** ```json { "content": { "sections": [ { "type": "SECTION_TYPE", "order": 1, "data": { ... } }, { "type": "SECTION_TYPE", "order": 2, "data": { ... } } ] } } ``` ### Step 6.5: Create multi-language versions (optional) If the user wants their page in multiple languages, create additional locale variants using the same slug with a different `locale`: ```bash # Create Japanese version curl -X POST https://appai.info/api/v1/pages \ -H "Authorization: Bearer USER_API_KEY_HERE" \ -H "Content-Type: application/json" \ -d '{"slug": "my-app", "locale": "ja", "title": "マイアプリ", "tagline": "素晴らしいアプリ", "content": {...}, "isPublished": true}' # Create Simplified Chinese version curl -X POST https://appai.info/api/v1/pages \ -H "Authorization: Bearer USER_API_KEY_HERE" \ -H "Content-Type: application/json" \ -d '{"slug": "my-app", "locale": "zh-CN", "title": "我的应用", "tagline": "一款很棒的应用", "content": {...}, "isPublished": true}' ``` **Multi-language URL structure:** - `appai.info/p/my-app` — default language (whichever locale is marked as default) - `appai.info/p/my-app/ja` — Japanese (if not the default) - `appai.info/p/my-app/zh-CN` — Simplified Chinese (if not the default) - `appai.info/p/my-app/ja/privacy` — Japanese privacy policy **How the default language works:** - The **first locale you create** for a slug automatically becomes the default - The default locale is shown at `/p/my-app` (no language suffix in the URL) - Non-default locales are shown at `/p/my-app/ja`, `/p/my-app/zh-CN`, etc. - You can change the default at any time with `POST /api/v1/pages/:slug/set-default?locale=ja` - **Ask the user what their primary language is** — create that locale first so it becomes the default **Example: Japanese developer creating a page** ```bash # Step 1: Create the Japanese version first (becomes default automatically) curl -X POST https://appai.info/api/v1/pages \ -H "Authorization: Bearer API_KEY" \ -H "Content-Type: application/json" \ -d '{"slug": "my-app", "locale": "ja", "title": "マイアプリ", ...}' # → appai.info/p/my-app shows Japanese (it's the default) # Step 2: Add English translation curl -X POST https://appai.info/api/v1/pages \ -H "Authorization: Bearer API_KEY" \ -H "Content-Type: application/json" \ -d '{"slug": "my-app", "locale": "en", "title": "My App", ...}' # → appai.info/p/my-app/en shows English # Optional: Change default to English later curl -X POST "https://appai.info/api/v1/pages/my-app/set-default?locale=en" \ -H "Authorization: Bearer API_KEY" # → Now appai.info/p/my-app shows English, appai.info/p/my-app/ja shows Japanese ``` **What happens automatically:** - **Browser language detection**: When a user visits `/p/my-app` (no locale suffix), the system checks their browser's `Accept-Language` header. If the browser prefers Japanese and a Japanese version exists, the user is automatically redirected to `/p/my-app/ja`. If the user manually clicks a language in the switcher, a cookie (`appai_locale`) is set so auto-detection won't override their choice. - A language switcher appears in the header when multiple locales exist - `hreflang` tags are added for SEO (search engines serve the right language) - JSON-LD structured data includes `inLanguage` - Sitemap includes all locale variants with alternates - `