SmartSpark-Final.py is a Python script that integrates OpenAI's GPT-3.5 Turbo with Smartsheet to generate and populate a structured task list for a given project type. The script takes user input for the project type and Smartsheet Sheet ID, generates a detailed task breakdown using OpenAI, and then inserts the structured task data into a specified Smartsheet.
- Generates project plans: Uses OpenAI's GPT-3.5 Turbo to create a structured, JSON-formatted task list based on a user-specified project type.
- Automated Smartsheet Integration: Fetches a target Smartsheet and populates it with generated tasks and durations.
- Secure API Key Handling: Uses environment variables for OpenAI and Smartsheet API keys.
- Error Handling: Ensures proper JSON response formatting and prevents invalid data entry.
- Python 3.8+
- An OpenAI API Key (
OPENAI_API_KEYstored in environment variables) - A Smartsheet API Key (
SMARTSHEET_API_KEYstored in environment variables) - Required Python libraries:
openaismartsheet-python-sdkjsonos
-
Clone the Repository (or copy the script):
git clone <repo-url> cd APItesting/2025
-
Install Dependencies:
pip install openai smartsheet-python-sdk
-
Set Environment Variables (Recommended):
export OPENAI_API_KEY="your_openai_api_key" export SMARTSHEET_API_KEY="your_smartsheet_api_key"
-
Run the script:
python SmartSpark-Final.py
-
Provide Input:
- Enter the project type when prompted.
- Enter the Smartsheet Sheet ID where tasks should be added.
-
Output:
- The script will generate a structured task plan in JSON format.
- It will then add the tasks and their durations to the specified Smartsheet.
The script generates tasks in the following JSON format:
{
"tasks": [
{
"task": "Define project scope",
"duration": "5"
},
{
"task": "Develop project plan",
"duration": "10"
}
]
}- Invalid JSON Response: If OpenAI's response is not in proper JSON format, the script exits with an error message.
- Missing or Invalid Sheet ID: Ensures that the Smartsheet API can retrieve the given sheet before attempting updates.
- Non-Numeric Durations: Extracts numeric values from OpenAI's duration estimates.
- Enhance task generation prompts: Refine OpenAI prompt for better accuracy and additional metadata.
- Flexible Column Mapping: Allow dynamic column selection for Smartsheet integration.
- Support for Additional AI Models: Extend compatibility with other OpenAI models.
MIT License (or specify if different).
Mike Kozub