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
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").
Send Prompt to API: The prompt and classifications are sent to the RapidAPI Classify API to be analyzed.
Process the API Response: The API returns a classification for the prompt, which is then processed.
Create a Record: The processed response is formatted and saved as a record in Contextual.
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.
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.
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.
Explanation:
msg.event.prompt
andmsg.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 tomsg.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.
Last updated