Back to Step Functions

aiProcessing

Advanced

Performs flexible AI-powered data processing using custom prompts for content generation, analysis, summarization, and classification.

overview

The aiProcessing function performs flexible AI-powered data processing using custom prompts. This function gives you complete control over how AI analyzes, transforms, or generates content based on your specific requirements.

Executes custom AI processing tasks using natural language prompts. Unlike the structured extraction of aiExtractVariables, this function is designed for open-ended AI tasks like content generation, analysis, summarization, classification, or any custom processing logic you can describe in a prompt.

Key Differentiator: Unlike aiExtractVariables which extracts specific structured data, aiProcessing allows open-ended AI tasks that you can describe in natural language prompts.

Key Capabilities

Custom Prompt Processing

Execute any AI task you can describe in natural language

Flexible Output Formats

Return results as plain text or structured JSON

Image Analysis

Can extract information from images when provided with image buffers

Content Generation

Create new content based on input data and instructions

Data Transformation

Convert data between formats or apply complex business logic

input_parameters

ParameterTypeRequiredDescription
promptstringNatural language instructions for the AI to follow
output_typestringOptionalFormat of response: "text" (default) or "json"
image_bufferbufferOptionalImage data to analyze alongside text
image_mimetypestringOptionalMIME type of the image (e.g., "image/png")

Expected Outputs

Text Output (Default)

Returns the AI's response as a string:

Text Response

JSON Output

Returns parsed JSON object when output_type: "json":

JSON Response

Error Response

When processing fails:

Error Output

Usage Examples

Simple Text Processing Example

Basic conversation summarization using aiProcessing:

Conversation Summarization

JSON Output Example

Analyzing customer sentiment and returning structured data:

Customer Sentiment Analysis

Image Processing Example

Analyzing document images alongside text prompts:

Document Image Analysis

Data Transformation Example

Converting data formats for API integration:

API Format Conversion

Advanced Content Generation Example

Generating professional email responses with specific requirements:

Email Response Generation

Using Previous Step Data

Creating comprehensive reports by combining data from multiple workflow steps:

Business Report Creation

JSON Output Note: When using output_type: "json", you must include a request in the prompt to respond as a JSON Object (e.g. "Provide your response as a JSON Object").

Best Practices

Be Specific in Prompts

Clear, detailed instructions produce better results. Specify exactly what you want the AI to do and what format you expect.

  • Provide clear, detailed instructions about what you want the AI to accomplish
  • Specify exactly what format you expect in the output
  • Include examples in your prompts when they help clarify requirements

Use Output Type Appropriately

Choose "json" when you need structured data that other steps can easily reference, and "text" for human-readable content.

  • Choose "json" when you need structured data for other steps to reference
  • Choose "text" for human-readable content and final responses
  • When using "json", explicitly request JSON Object format in your prompt

Include Context

Reference previous step outputs and relevant variables to give the AI complete context for processing.

  • Reference previous step outputs using variable interpolation
  • Include relevant variables and context from your workflow
  • Provide complete context so the AI can make informed decisions

Handle Variable Data

When working with data from previous steps, ensure your prompts can handle variations in data structure and content.

  • Ensure your prompts can handle variations in data structure and content
  • Structure your requests to work with different input scenarios
  • Consider token limits when working with very long prompts or large amounts of input data

Related Functions

These functions complement aiProcessing for building comprehensive AI-powered workflows: