Skip to content

# Auto-Categorize Help Requests Using Lambda Function #100

@saquibb8

Description

@saquibb8

Auto-Categorize Help Requests Using Lambda Function

User Story

As a platform administrator,
I want incoming help requests to be automatically categorized based on their subject and description,
So that requests are routed to the correct category and subcategory — even if the user selected the wrong one.


⚠️ Developer Note

This task should be developed and tested locally. The team leads will handle deploying the Lambda function once it is working.

To understand the full request submission flow and see the existing categories/subcategories, use the test environment as a playground: https://test-saayam.netlify.app/

For the webapp codebase, clone the webapp repository and follow the setup and contribution instructions in that repo's README.


Background

Our platform allows users to submit help requests by providing a subject, description, and selecting a category and subcategory. In practice, users sometimes select the wrong category — for example, someone describing a need for temporary housing might categorize it under "General" instead of "Shelter."

We need a Lambda function that uses the request's subject and description to intelligently determine the correct category and subcategory from our existing predefined list. This will be used to either auto-assign categories for new requests or flag miscategorized ones for review.


Objective

Build an AWS Lambda function that accepts a help request's subject and description, analyzes the content, and returns the most appropriate category and subcategory from the existing predefined set.


Scope

In Scope

  • Create a new Lambda function that accepts subject and description as input
  • Use an LLM/GenAI approach (or rule-based NLP) to classify the request into one of the existing categories and subcategories
  • Return a predicted category and subcategory along with a confidence score
  • Handle edge cases: vague descriptions, multilingual input, requests that could fall into multiple categories
  • Since we run on tight budgets, try to have the functions use as many less LLM API credits as possible

Out of Scope

  • Frontend integration (separate task)
  • Creating new categories or subcategories
  • Modifying the existing request submission flow
  • Automatic overwriting of user-selected categories (this function provides a suggestion only)

Existing Categories

Important: Visit https://test-saayam.netlify.app/ and go through the request submission flow to see the full list of categories and subcategories currently available. The Lambda must only return values from this existing set.


Technical Details

Lambda Input

{
  "subject": "I need a place to stay tonight",
  "description": "I just lost my apartment and I'm on the streets. I have two kids with me and we need somewhere safe to sleep."
}

Expected Lambda Output

{
  "statusCode": 200,
  "body": {
    "category": "Shelter",
    "subcategory": "Emergency Shelter",
    "confidence": 0.92,
    "reasoning": "Request describes immediate need for housing due to loss of apartment with dependents, indicating emergency shelter need."
  }
}

Implementation Considerations

  • Approach: Use an LLM (e.g., Amazon Bedrock, OpenAI API) with a prompt that includes the full list of valid categories/subcategories and asks it to classify the input. Alternatively, a lightweight rule-based or embedding-similarity approach could work if latency/cost is a concern.
  • Category list: The valid categories and subcategories should be maintained as a config/constant within the Lambda so they can be easily updated.
  • Confidence threshold: Include a confidence score so downstream consumers can decide whether to auto-assign or flag for human review.
  • Error handling: Return a sensible default or an "Uncategorized" response if the function cannot determine a category with reasonable confidence.

Acceptance Criteria

  • Lambda function accepts subject and description as input via POST
  • Lambda returns a valid category and subcategory from the existing predefined list — never invents new ones
  • Lambda returns a confidence score (0–1) indicating classification certainty
  • Lambda returns a brief reasoning explanation for the classification
  • Handles vague or ambiguous input gracefully (returns best guess with lower confidence or "Uncategorized")
  • Handles empty or missing subject or description without crashing
  • Response time is reasonable (< 5 seconds including cold start)
  • Tested with at least 10 diverse sample requests covering different categories

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions