LogoLogo
Visit Contextual.ioSign Up
  • Getting Started
    • Welcome
    • Tour: Hello, AI World!
  • TRAINING
    • Basic Developer Training Course
      • Lesson 1: HTTP Agent Introduction
      • Lesson 2: Logging and Error Handling Basics
      • Lesson 3: Event Processing Agent Introduction
  • Services Catalog
    • What's in the Catalog?
      • Intro Patterns
      • Object Type Bundles
    • Browse by Platform
    • All Intro Patterns
      • Anthropic Claude Image Analysis
      • Mistral AI Prompt and Response
      • xAI Grok Prompt and Response
      • DeepSeek Chat Prompt and Response
      • Qwen Chat Prompt and Response
      • Perplexity AI Search and Response
      • Firecrawl Website Scraper
      • Groq Prompt and Response
      • Nyckel Dog Breed Classification
      • RapidAPI ClassifyAI Text Classification
      • RapidAPI YouTube AI Video Summary
      • UnifyAI Model Comparison
      • WebPilot URL Analysis and Summarization
      • OpenAI Assistants Prompt and Response
      • OpenAI Sync
    • All Prebuilt Solutions
      • Invoice AI
      • Lead Generation Form
    • All Object Type Bundles
      • Work Order Management System ITIL Object Type Bundle
        • Work Order
        • User
        • Role
        • Permission
        • Asset
        • Task
        • Action
        • Attachment
        • Comment
        • Notification
        • Audit Log
        • Service Level Agreement
        • Custom Fields
        • Work Order Template
        • Work Order Transition
        • Escalation Policy
        • Tag
  • Components & Data
    • Object Types
      • Data in Contextual
        • Secrets
        • Validation
        • Versioning
      • Examples
      • Creating an Object Type
      • Object Type Details
        • Definition
        • Data Schema
          • Automatic Record Metadata
          • Generated Values
            • Dates and Times
            • UUIDs
          • Frequently Used Validation
          • Disallowing Null Property Values
          • Disallowing Undefined Properties
          • Secrets
          • AI Assistant
          • ID and PrimaryKey Permanence
        • UI Schemas
        • Features
        • Triggers
        • Actions
        • Audit Trail
        • Versions
        • Templates
        • Records
      • Using Object Types in Flows
      • Records
        • Records and Your Tenant API
        • Record Import
    • Flows
      • Nodes
      • Wires
      • Message Object
      • Flow Editor
        • Basics
        • Saving Changes
        • In-Flow Testing with Debugger
        • Restart Agents to Make Changes Active
        • Config
      • Node Reference
        • Common
          • Log Tap
          • Inject
          • Debug
          • Complete
          • Catch
          • Status
          • Link In
          • Link Call
          • Link Out
          • Comment
        • Event
          • Prepare Event
          • Event Start
          • Event End
          • Event Error
        • Object
          • Search Object
          • Get Object
          • Create Object
          • Patch Object
          • Put Object
          • Delete Object
          • Run Action
        • Request
          • Send to Agent
          • HTTP GET
          • HTTP PATCH
          • HTTP PUT
          • HTTP DELETE
          • HTTP POST
          • GQL
          • Produce Message
        • Function
          • Function
          • Switch
          • Change
          • Range
          • Template
          • Delay
          • Trigger
          • Exec
          • Filter
          • Loop
        • Models
          • ML Predict
        • Network
          • MQTT In
          • MQTT Out
          • HTTP In
          • HTTP Response
          • HTTP Request
          • WebSocket In
          • WebSocket Out
          • TCP In
          • TCP Out
          • TCP Request
          • UDP In
          • UDP Out
        • Sequence
          • Split
          • Join
          • Sort
          • Batch
        • Parser
          • csv
          • html
          • json
          • xml
          • yaml
    • Agents
      • Creating an Agent
      • Types of Agents
        • Event to Flow
        • HTTP to Flow
          • Custom Domains
      • How Agents Work
        • Flow Execution
        • HTTP Load Balancing
        • Event Routing
      • Scale and Performance
        • Flow execution
        • Parallel Instances
        • Event Lag Scaling
        • Compute Threshold Scaling
        • Instance Compute Sizing
      • Agent Details
        • Definition
        • Operations
        • Logs
          • Session Log
          • Message Log
        • Audit Trail
        • Versions
      • Using Agents in Flows
    • Connections
      • Creating a Connection
      • Types of Connections
        • Basic
        • Bearer
        • Client Grant
        • Kafka
        • Password Grant
        • Public
        • Pulsar
      • Using Connections in Flows
    • JWKS Profiles
      • Using JWKS Profiles in Your Solution
  • PATTERNS
    • Solution Architecture
      • Events, Messages, Queues
    • Working with Data
      • Search Object Node & Pagination
      • Message Payload Content - Triggers and Actions
    • Industry Cookbooks
      • Field Services
  • Tenants
    • Tenant Workspace
    • Tenant Logs
      • Contextual Log Query Language (CLQL)
        • String Searches
        • Keyword Searches
        • Advanced Operators
    • Tenant API
      • API Keys
        • API Key Settings
        • API Key Permissions
      • Documentation
  • Release Notes
    • 2024
      • 2024.12.09
Powered by GitBook
On this page
  • What's Included
  • What You'll Need
  • Ideas for Using Text Classification
  • Flow Overview
  • Details

Was this helpful?

  1. Services Catalog
  2. All Intro Patterns

RapidAPI ClassifyAI Text Classification

The RapidAPI ClassifyAI Text Classification solution has broad application in leveraging AI for classification. Useful for automatically classifying text inputs and storing the results for further use or analysis in go-to-market, service delivery, operations, IOT and data transformation AI solutions.

This template can be found in the Services Catalog in these categories:

  • AI, Contextual Basics

What's Included

  • 1 Flow

  • 1 Object Type

  • 1 Connection

What You'll Need

  • A RapidAPI ClassifyAI API Key

Ideas for Using Text Classification

Customer Sentiment Analysis for Go-to-Market Strategies

Use text classification to analyze customer feedback, reviews, and social media mentions to determine sentiment trends. This insight can help tailor marketing campaigns, product messaging, and customer engagement strategies, driving higher conversion rates and better customer satisfaction.

Predictive Maintenance Alerts in IoT

Classify incoming text data from IoT sensors, such as logs or alerts, to predict potential equipment failures. This can improve operational efficiency by enabling proactive maintenance, reducing downtime, and extending the life of critical assets.

Automated Lead Scoring for Sales Optimization

Implement text classification to automatically score and prioritize sales leads based on their email inquiries, social media interactions, or responses to marketing materials. This can enhance the efficiency of the sales team by focusing efforts on the most promising prospects.

Document Classification in Enterprise Data Applications

Use text classification to automatically categorize and tag large volumes of unstructured enterprise data, such as emails, reports, and contracts. This improves data retrieval, ensures compliance, and streamlines business processes by making relevant information more accessible.

Field Service Request Prioritization

Classify incoming service requests or incident reports based on urgency and type of issue. This enables field service teams to prioritize their tasks effectively, leading to faster resolution times, improved customer satisfaction, and better resource allocation.

Flow Overview

  1. Flow Start: It begins by receiving a prompt (a question or text - such as "F1 Race Car") and a set of possible classifications (like "slow," "average," "very fast").

  2. Send Prompt to API: The prompt and classifications are sent to the RapidAPI Classify API to be analyzed.

  3. Process the API Response: The API returns a classification for the prompt, which is then processed.

  4. Create a Record: The processed response is formatted and saved as a record in Contextual.

  5. Error Handling: There’s a mechanism to catch and log any errors that occur during the flow. If there are errors, they'll show up in either the Flow Editor Debug pane or in Agent Logs if you pair this flow with an Agent.

  6. Flow End: The flow completes its process after the record is created or an error is handled.

Details

The flow includes several JavaScript function nodes that handle various tasks. Here’s a more detailed breakdown of the JavaScript involved in this flow:

Here’s a re-ordered and detailed breakdown of the JavaScript involved in this flow, following the order of the flow itself:

1. Inject Node

  • Node: Test Prompt

  • Purpose: This node provides the initial data (prompt and classes) for testing within the Flow Editor by clicking the button on the node itself. You can edit the values to test various inputs.

  • Explanation:

    • The node injects a sample prompt ("F1 Race Car") and a set of possible classifications ("slow, average, very fast") into the flow. These values are manually set for testing purposes.

2. Prepare Prompt Function

  • Node: Prepare Prompt

  • Purpose: This function prepares the data to be sent to the RapidAPI Classify API by formatting the input into the required structure.

// Prepare the payload for RapidAPI Classify API request
msg.payload = {
    // Set the 'text' field with the prompt to be classified
    // This assumes the original prompt is stored in msg.payload.prompt
    text: msg.payload.prompt,

    // Set the 'classes' field with an array of possible classification categories
    // This assumes the classes are provided as a comma-separated string in msg.payload.classes in "Test Prompt" node
    // The split function converts this string into an array of individual class names
    classes: msg.payload.classes.split(', ')
};

// Return the modified msg object
return msg;
  • Explanation:

    • msg.payload.prompt: Contains the text prompt that needs classification.

    • msg.payload.classes: Holds a string of classification categories separated by commas (e.g., "slow, average, very fast").

    • The function splits the classes string into an array using .split(', '), making it compatible with the API’s expected input format.

    • The modified msg.payload is returned for further processing.

3. API Interaction

  • Node: Prompt RapidAPI Classify

  • Purpose: Sends the formatted prompt and classes to the RapidAPI Classify API, and retrieves the classification response.

  • Explanation:

    • The HTTP POST request is made using the data prepared by the previous node (msg.payload).

    • The API’s response, containing the classification, is stored in msg.payload.response.

4. Prepare Record Data Function

  • Node: Prepare Record Data

  • Purpose: This function formats the API response and prepares it to be saved as a record in the system.

// Prepare data for Create Object node and assign to msg.payload
let body = {
    // 'prompt' is a property of the JSON Data Schema that this value will populate
    prompt: msg.event.prompt,
    classes: msg.event.classes,
    // 'aiResponse' is a property of the JSON Data Schema that this value will populate
    // The value is being extracted from the RapidAPI Classify API response
    aiResponse: msg.payload.response.data.Class
}

// The Create Object node will use the content of msg.payload to create a new record
msg.payload = body;

return msg;
  • Explanation:

    • msg.event.prompt and msg.event.classes: These fields capture the original prompt and classification categories from the event that triggered this flow.

    • msg.payload.response.data.Class: Extracts the classification result from the API response. The exact property name (data.Class) depends on the structure of the API response.

    • A new object, body, is created to store the prepared data, which is then assigned to msg.payload.

    • The msg.payload is returned and passed to the next node, which will create a new record based on this data.

5. Record Creation

  • Node: Create AI Response Record

  • Purpose: This node creates a new record in the system using the formatted data from the previous node.

  • Explanation:

    • The node uses the prepared msg.payload to create a new record, which stores the original prompt, the possible classifications, and the AI’s response.

6. Error Handling

  • Nodes:

    • Catch

    • Error Catch Log

  • Purpose: This part of the flow catches any errors that occur during the process and logs them.

  • Explanation:

    • The catch node captures any errors in the flow.

    • The log-tap node logs these errors to the side panel or console, depending on its configuration.

    • The error logging node uses built-in Node-Red functionality to handle the error without requiring additional custom JavaScript.

Summary of Flow:

  • Flow Start: A sample prompt and classification options are injected.

  • Data Preparation: The prompt and classifications are formatted for the API request.

  • API Interaction: The formatted data is sent to RapidAPI Classify, and the response is received.

  • Record Creation: The API’s response is formatted and stored as a record.

  • Error Handling: Any errors during the flow are caught and logged.

These JavaScript snippets are crucial in formatting the data correctly and ensuring that the flow runs smoothly from start to finish.

PreviousNyckel Dog Breed ClassificationNextRapidAPI YouTube AI Video Summary

Last updated 8 months ago

Was this helpful?

RapidAPI ClassifyAI Flow
Page cover image