Twition

v1.0.0

Simple, elegant automation

Base URL:https://twition.shubhojeet.com
What does this do?
Transform your Notion tasks into Twitter posts automatically. One button click reads your completed tasks, creates engaging content with AI, and posts to Twitter.
How it works
1

Read Notion

2

Generate Content

3

Post to Twitter

2
Endpoints
Automate + Status
4
Services
Notion + AI + Twitter + Email
Reliability
Enhanced monitoring
Setup
Configure your API keys once. No authentication needed in requests.
You need these API keys:
Notion API Key
Get from developers.notion.com
Twitter API Keys
Get from developer.twitter.com
Gemini AI Key
Get from ai.google.dev
Email Settings
For notifications
✓ Environment Validation
The API automatically validates all required environment variables on startup and provides detailed error messages for missing configurations.
API Endpoints
Just two simple endpoints
POST
/api/automate
This does everything: reads your Notion tasks, creates Twitter content with AI, and posts it.

How to use it

# Basic automation
curl -X POST https://twition.shubhojeet.com/api/automate
# With specific Notion page
curl -X POST "https://twition.shubhojeet.com/api/automate?pageId=your-page-id"

Success Response (200)

{
  "success": true,
  "message": "Successfully posted 2 tweet(s) from 3 completed task(s)",
  "data": {
    "tasks": {
      "count": 3,
      "titles": ["Task 1", "Task 2", "Task 3"]
    },
    "content": {
      "type": "thread",
      "tweets": 2
    },
    "twitter": {
      "tweetIds": ["123456789", "987654321"],
      "success": true
    },
    "timing": {
      "startTime": "2024-01-15T10:30:00Z",
      "endTime": "2024-01-15T10:30:05Z",
      "duration": "5000ms"
    }
  },
  "metadata": {
    "stage": "completed",
    "source": "unified-automation-endpoint",
    "version": "1.0.0"
  }
}

No Tasks Response (200)

{
  "success": true,
  "message": "No completed tasks found for today",
  "action": "skipped",
  "tasks": []
}

Error Response (500)

{
  "success": false,
  "message": "Automation workflow failed",
  "error": {
    "message": "Twitter API rate limit exceeded",
    "stage": "twitter-posting",
    "timestamp": "2024-01-15T10:30:00Z"
  },
  "debug": {
    "startTime": "2024-01-15T10:29:55Z",
    "failedAt": "2024-01-15T10:30:00Z",
    "stage": "twitter-posting"
  }
}
GET
/api/automate
Check if the API is working.

Request

curl https://twition.shubhojeet.com/api/automate

Response (200)

{
  "status": "ready",
  "message": "Unified automation endpoint is ready",
  "configuration": {
    "environment": "valid"
  },
  "endpoints": {
    "trigger": "POST /api/automate",
    "health": "GET /api/automate"
  },
  "timestamp": "2024-01-15T10:30:00Z"
}
GET
/api/status
See detailed system health and connection status.

Request

curl https://twition.shubhojeet.com/api/status?detailed=true

Response (200)

{
  "status": "healthy",
  "service": "twitter-automation",
  "timestamp": "2024-01-15T10:30:00Z",
  "integrations": {
    "notion": {
      "status": "healthy",
      "connected": true,
      "description": "Notion database connection for task retrieval"
    },
    "twitter": {
      "status": "healthy", 
      "connected": true,
      "description": "Twitter API connection for posting tweets"
    },
    "email": {
      "status": "healthy",
      "connected": true,
      "description": "Email service for error and success notifications"
    },
    "gemini": {
      "status": "configured",
      "connected": true,
      "description": "Google Gemini AI for content generation"
    }
  },
  "errorHandling": {
    "initialized": true,
    "globalErrorHandlers": "active",
    "emailNotifications": "enabled",
    "features": [
      "Retry mechanism with exponential backoff",
      "Detailed error context and stack traces",
      "Stage-based error tracking"
    ]
  },
  "overall": {
    "status": "healthy",
    "allServicesHealthy": true,
    "message": "All systems operational with enhanced error handling"
  }
}
Ways to use it
Pick what works best for you

🔘 Notion Button (Easiest)

Add a button to your Notion page:

  • 1. Type /button in Notion
  • 2. Set URL to: https://twition.shubhojeet.com/api/automate?pageId=62821820-ea75-4dca-b0e6-f1bb857c58a2
  • 3. Set Method to: POST
  • 4. Click the button to post your completed tasks!

📱 JavaScript/Fetch

fetch('/api/automate', {
  method: 'POST'
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

🔗 Command Line

curl -X POST https://twition.shubhojeet.com/api/automate
When things go wrong
Common error messages and what they mean
Status CodeError StageDescription
500environment-validationMissing required environment variables
500notion-fetchFailed to connect to Notion API or fetch tasks
500gemini-generationAI content generation failed
500twitter-postingTwitter API error or rate limit exceeded
200successAutomation completed successfully