Skip to content

AI: Classify document

The "AI: Classify document" service task automatically assigns a given text to one of the provided categories. Classification is performed via AI (OpenAI) and returns the matched category along with a confidence score between 0 and 1.

Typical use cases include automatic sorting of incoming documents (e.g. invoice, quote, dunning letter) or pre-qualifying support requests.

Input parameters

Provide the following fields as task input:

{
  "text": "Dear Sir or Madam, please find attached our invoice no. 2024-001 for EUR 1,500.00.",
  "categories": ["Invoice", "Quote", "Dunning letter", "Order", "Other"]
}

Explanation:

  • text: The text to classify. It can originate from a document, an email, or a form field.
  • categories: An array with at least two categories. The AI selects exactly one of them.

Output

The task returns the detected category and a confidence score:

{
  "category": "Invoice",
  "confidence": 0.95
}

Explanation:

  • category: The detected category – always exactly one of the values defined in the input.
  • confidence: A number between 0 and 1 indicating how certain the classification is (1 = very confident).

JSONata examples

// Example: classify text from a previous step
{
  "text": stepResult.extractedText,
  "categories": ["Invoice", "Quote", "Dunning letter", "Complaint", "Other"]
}
// Example: continue only if confidence is high (gateway condition)
result.confidence > 0.8

Notes

  • At least two categories are required.
  • Categories can be freely chosen – there are no restrictions on naming.
  • Longer and more descriptive texts lead to better results.
  • The confidence score is well-suited as a condition in a subsequent gateway (e.g. trigger a manual review when confidence is low).

Tip

Combining this task with the "Extract text from PDF" service task is particularly effective: first extract the text from a PDF, then classify it automatically.