A Next.js web application that allows non-technical users to easily export helpdesk ticket data from Klaviyo to CSV format.
- Simple, user-friendly interface
- Export closed tickets with performance metrics
- Calculates time-to-close for each ticket
- Supports multiple time periods (Last 24 Hours, Last Week, Last Month)
- Secure - API keys are never stored
- Handles pagination automatically for large datasets
- Node.js 18+ installed
- A Klaviyo account with API access
- Metric IDs for "Ticket Created" and "Ticket Closed" events
- Install dependencies:
npm install- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
npm run build
npm start- Log in to your Klaviyo account
- Go to Settings → API Keys
- Create a new private API key or use an existing one
- Copy the key (it starts with
pk_)
- In Klaviyo, go to Analytics → Metrics
- Search for "Ticket Created" metric
- Click on the metric
- Copy the metric ID from the URL (format:
metric_id_xxxxx) - Repeat for "Ticket Closed" metric
- Enter your Klaviyo Private API Key
- Enter the Metric ID for "Ticket Created"
- Enter the Metric ID for "Ticket Closed"
- Select your desired time period:
- Last 24 Hours
- Last Week
- Last Month
- Click "Export to CSV"
- The CSV file will automatically download
The exported CSV includes one row for each event, with dynamic columns based on the event properties.
- Event ID: Klaviyo event ID
- Event Type: Either "Ticket Created" or "Ticket Closed"
- Event Date Time: Timestamp when the event occurred
- Ticket ID: Unique identifier for the ticket
All event properties from your Klaviyo events are automatically included as additional columns. The CSV will contain a column for every unique property found across all events.
Event ID,Event Type,Event Date Time,Ticket ID,customer_email,customer_name,priority,subject,ticket_id
"evt_abc123","Ticket Created","2025-11-28T10:30:00.000Z","12345","[email protected]","John Doe","high","Login issue","12345"
"evt_def456","Ticket Closed","2025-11-28T14:45:00.000Z","12345","[email protected]","John Doe","high","Login issue","12345"
"evt_ghi789","Ticket Created","2025-11-28T11:00:00.000Z","12346","[email protected]","Jane Smith","normal","Billing question","12346"
"evt_jkl012","Ticket Closed","2025-11-28T12:30:00.000Z","12346","[email protected]","Jane Smith","normal","Billing question","12346"
Note: The CSV is sorted by Ticket ID, with "Ticket Created" events appearing before "Ticket Closed" events for the same ticket. Empty cells indicate properties that don't exist on that particular event.
For detailed information about the CSV format, including how to analyze the data, see CSV_FORMAT.md.
- The application makes API calls to Klaviyo's
get_eventsendpoint - It fetches all events for both "Ticket Created" and "Ticket Closed" metrics within the specified time period
- Each event is added as a separate row in the CSV
- Results are sorted by Ticket ID, with "Ticket Created" events appearing before "Ticket Closed" events for the same ticket
- Uses Klaviyo API v2024-10-15
- Implements automatic pagination to fetch all events
- Filters events by metric ID and date range
- Handles rate limiting gracefully
- API keys are only used for the request and never stored
- All API calls are made server-side to protect credentials
- No data is persisted or logged
- Check that your API key is correct and has the necessary permissions
- Ensure the API key has not expired
- Verify that your metric IDs are correct
- Make sure you're using the metric IDs, not metric names
- Verify that you have ticket events within the selected time period
- Check that the ticket ID field exists in the event properties
- Ensure both metrics are properly configured in Klaviyo
- Large time periods with many events will take longer to process
- The app fetches all events before generating the CSV
- Consider using a shorter time period for faster exports
The application includes comprehensive logging to help verify that API calls are working:
- Server logs (terminal): Shows all Klaviyo API calls, responses, and data processing
- Client logs (browser console): Shows export initiation and completion
See TESTING.md for detailed instructions on how to verify the API calls are working.
helpdesk-export/
├── app/
│ ├── api/
│ │ └── export/
│ │ └── route.ts # API endpoint for fetching and processing data
│ ├── globals.css # Global styles
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main UI component
├── public/ # Static assets
├── package.json # Dependencies
└── tsconfig.json # TypeScript configuration
- Next.js 15 (App Router)
- TypeScript
- Tailwind CSS
- Klaviyo Events API
MIT