Welcome to Survey Says — Assignment Seven

Remote AI API Categorization

In this assignment, you will extend Survey Says so an administrator can send survey responses to a remote AI API and review the category assignments it returns.

The goal is not simply to call an AI service. You will design a dependable request-and-review process that keeps the original response data, validates the AI's structured result, and lets an administrator decide what becomes part of the application database.

An illustration of a survey application sending response data to a remote artificial intelligence service and receiving categorized results, with visual indicators for tokens and request rate limits.
Send compact response data to a remote AI service, then carefully validate and apply its structured category assignments.

What will you practice?

You will practice communicating with a remote AI API: creating a focused prompt, sending JSON over HTTP, reading a structured JSON response, and treating returned data as untrusted until your application validates it. You will also learn why token counts matter: both the prompt and the AI response consume tokens, so concise data, batching, and reusable categories help control a free account's rate and token limits.

A practical workflow

  1. Build database models for canonical categories and each response's category assignment.
  2. Create view models that contain only the information each administrator page needs.
  3. In a new controller, select uncategorized responses and send a compact request to the remote AI API.
  4. Validate every returned response ID and category before showing an administrator a review page.
  5. Apply approved assignments to the database, then support later requests for new responses only.
  6. Optimize thoughtfully by reusing known categories, batching work, and displaying token and rate-limit information for troubleshooting.