Back to Step Functions

sendResponse

Beginner

Sends final messages back to users through the ChatBot interface and marks the workflow as completed, ending workflow execution.

overview

The sendResponse function allows your workflow to send messages back to the user through the ChatBot interface and always marks the workflow as completed, ending the workflow execution. This is the final communication step in any workflow.

Send final messages to users and complete the workflow. This function serves as the definitive endpoint for workflow execution, ensuring users receive final results while properly terminating the workflow process.

Critical Behavior: The sendResponse function ALWAYS ends workflow execution regardless of the response type. No steps after sendResponse will ever execute.

Common Use Cases

Final Communication

  • Delivering final workflow results
  • Confirming successful completion
  • Providing summary reports
  • Ending workflows with status updates

Workflow Termination

  • Graceful workflow ending
  • Prevent further execution
  • Clean completion state
  • Final user notification

input_parameters

ParameterTypeRequiredDescription
typestringResponse delivery method: "fixed" or "ai"
messagestringFinal content to send to the user

Response Types

Fixed Response ("fixed")

Sends the message directly to the user exactly as written, without AI processing, then completes the workflow

Best For:

  • Structured final reports
  • Formatted completion summaries
  • Direct result delivery
  • Confirmation messages

AI-Enhanced Response ("ai")

Processes the message through AI to create a more natural, conversational final response, then completes the workflow

Best For:

  • Conversational completion messages
  • Context-aware final summaries
  • Natural language result presentation
  • Dynamic final content

Fixed Response Example

Structured Completion

AI-Enhanced Response Example

Conversational Completion

Workflow Completion Behavior

Notify users when automated processes complete:

Wrong Usage

Incorrect Workflow Design

Correct Usage

Correct Workflow Design

Remember: Once sendResponse executes, your workflow is complete and no further steps will run. Plan your workflow structure accordingly to ensure all necessary processing occurs before the final response.

When to Use sendResponse vs promptUser

Use sendResponse when

  • You want to end the workflow
  • Providing final results or summaries
  • Confirming successful completion
  • No further user interaction is needed

Use promptUser when

  • You need additional information from the user
  • The workflow should continue after user response
  • Collecting missing required data
  • Asking for confirmation before proceeding

Usage Examples

Simple Workflow Completion

Basic workflow completion with a status message:

- id: schedule_complete function: sendResponse input: type: fixed message: "Your database monitoring alert has been scheduled and is now active."

Comprehensive Final Report

Detailed completion message with dynamic content and formatting:

Detailed Analysis Completion

Conditional Final Messages

Dynamic completion messages based on workflow results:

Dynamic Completion Status

Variable Integration

The sendResponse function fully supports variable interpolation for dynamic final message content:

Email Then Response Pattern

Common pattern of sending detailed information via email, then providing a summary response:

Email Notification + Completion

Conditional Completion Based on Results

Adapting the final message based on workflow outcomes:

Error-Aware Completion

Content Size Management: The function includes automatic content size management with a 40,000 character maximum. Oversized content is automatically truncated with a warning message.

Best Practices

Completion Clarity

Make it clear to users that the process has finished and what was accomplished.

  • Clearly indicate that the process is complete
  • Summarize what was accomplished
  • Provide any necessary follow-up actions

User Value

Ensure the final message provides value and actionable information to the user.

  • Include key results or findings
  • Highlight important information that requires attention
  • Provide context for next steps

Professional Communication

Maintain appropriate tone and formatting for your audience and use case.

  • Use appropriate tone for your audience
  • Include relevant details without overwhelming
  • Format complex information clearly

Workflow Design

Structure your workflows properly to ensure clean completion and resource management.

  • Ensure concludeWorkflow is the final step in your workflow
  • Use promptUser for any mid-workflow communication
  • Place all processing steps before the final sendResponse

Related Functions

These functions complement sendResponse for building complete user communication workflows: