> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wizflow.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Triggers & Automation

> Automate actions and integrate with external systems when users complete your chatflows

Triggers are the powerhouse of Wizflow automation, enabling sophisticated workflows that extend far beyond simple form collection into full business process automation. When users interact with your chatflow, triggers automatically execute actions, send data to external systems, generate documents, and perform complex calculations.

## How Triggers Work

<CardGroup cols={2}>
  <Card title="Event-Driven Actions" icon="bolt">
    Triggers execute automatically based on user interactions - when responses are created, updated, or deleted in your chatflow.
  </Card>

  <Card title="Dynamic Content" icon="sparkles">
    All triggers support dynamic content using user responses, variables, and other trigger outputs for personalized automation.
  </Card>

  <Card title="Flexible Timing" icon="clock">
    Choose instant execution (blocking) or event-based triggers that run in the background without interrupting user experience.
  </Card>

  <Card title="Error Handling" icon="shield-check">
    Built-in status reporting and error handling ensure reliable execution of critical business processes.
  </Card>
</CardGroup>

## Trigger Types

<Tabs>
  <Tab title="Email Automation">
    **Email Trigger**

    Send automated emails with dynamic content, attachments, and professional formatting based on user responses.

    **Perfect For:**

    * Welcome emails and confirmations
    * Application status notifications
    * Document delivery and reports
    * Customer onboarding sequences
    * Approval and rejection notices

    **Features:**

    * Template support with variable substitution
    * Multiple recipients and CC/BCC
    * File attachments from other triggers
    * Custom reply-to configuration
    * Professional HTML formatting

    ```yaml theme={null}
    Example: Send personalized loan pre-approval letter
    - To: applicant email
    - Subject: "Your loan application status - {{applicantName}}"  
    - Attach: PDF report from calculation trigger
    - Template: Professional branded email template
    ```
  </Tab>

  <Tab title="Document Generation">
    **PDF Trigger**

    Generate professional PDF documents dynamically from templates, user responses, or external data sources.

    **Perfect For:**

    * Contracts and agreements
    * Financial reports and statements
    * Certificates and confirmations
    * Application summaries
    * Regulatory compliance documents

    **Generation Options:**

    * **Custom HTML Templates** - Full design control
    * **Chatflow Summaries** - Automatic response compilation
    * **URL-based Generation** - Dynamic web page conversion
    * **Rich Text Content** - Formatted text documents
    * **Fillable PDF Forms** - Interactive document completion

    ```yaml theme={null}
    Example: Generate loan agreement
    - Template: Custom HTML with company branding
    - Data: User responses + calculation results
    - Output: Signed PDF ready for download
    - Formatting: Professional financial document layout
    ```
  </Tab>

  <Tab title="Image Generation">
    **AI Image Generator**

    Generate dynamic, personalized images during conversations using AI based on user data and responses.

    **Perfect For:**

    * Personalized user avatars
    * Custom persona visualizations
    * Dynamic product mockups
    * Data-driven infographics
    * User-specific visual content

    **Supported Models:**

    * **GPT Image 1** - OpenAI's image generation with full format control
    * **GPT-5 Image** - Latest OpenAI model (via Openrouter)
    * **GPT-5 Image Mini** - Faster, cost-effective option
    * **Gemini 2.5 Flash Image** - Google's fast image generation

    **Configuration:**

    * **GPT Image 1**: Quality control, format options (PNG/JPEG/WebP), compression, transparent backgrounds
    * **Other Models**: Image sizes
    * **All Models**: Prompt, Automatically cached for faster subsequent loading

    ```yaml theme={null}
      Example: Generate user persona avatar
      - Prompt: "Create avatar for {age}-year-old {occupation}"
      - Data: User responses from conversation
      - Output: Cached image URL
    ```
  </Tab>

  <Tab title="Financial Calculations">
    **Calculation Trigger**

    Advanced financial planning and pension optimization calculations with sophisticated algorithms that go beyond basic arithmetic.

    **Perfect For:**

    * Complex pension scenarios and projections
    * Wealth management calculations
    * Loan amortization schedules
    * Multi-variable financial modeling
    * Risk assessment computations

    **Capabilities:**

    * Professional-grade financial algorithms
    * Time series projections and modeling
    * Comprehensive financial data output
    * Chart and visualization data generation
    * Detailed calculation breakdowns

    ```yaml theme={null}
    Example: Pension optimization calculation
    - Input: Age, salary, current savings, goals
    - Processing: Complex actuarial calculations
    - Output: Projection charts, optimal contribution rates
    - Format: Structured data for reports and visualizations
    ```
  </Tab>

  <Tab title="External Integrations">
    **Webhook Trigger**

    Connect with external APIs and services for data exchange, CRM updates, and system integration.

    **Perfect For:**

    * CRM system updates (Salesforce, HubSpot)
    * Database operations and data storage
    * Third-party service integration
    * Real-time data synchronization
    * Payment processing integration

    **Features:**

    * Full HTTP method support (GET, POST, PUT, DELETE)
    * Custom headers and authentication
    * Path and query parameter support
    * OpenAPI integration for documentation
    * Response handling and error management

    ```yaml theme={null}
    Example: Update CRM with lead information
    - Method: POST to Salesforce API
    - Headers: Authorization, Content-Type
    - Payload: User responses formatted as lead data
    - Response: Lead ID for follow-up processes
    ```
  </Tab>

  <Tab title="Team Communication">
    **Slack Trigger**

    Send notifications and messages to Slack channels or users for team coordination and alerts.

    **Perfect For:**

    * New application alerts
    * High-priority lead notifications
    * Process completion updates
    * Error and exception reporting
    * Team workflow coordination

    **Features:**

    * Rich text formatting and markdown
    * Channel and direct message support
    * Webhook integration with Slack workspaces
    * Dynamic message content from user responses
    * Threaded conversations and replies

    ```yaml theme={null}
    Example: High-value lead notification
    - Channel: #sales-leads
    - Message: "🚨 High-value lead: {{customerName}} - {{loanAmount}}"
    - Format: Rich card with customer details and next steps
    - Threading: Automatic follow-up tracking
    ```
  </Tab>

  <Tab title="Analytics">
    **Analytics Trigger**

    Send tracking events to your marketing and analytics platforms whenever users interact with your chatflow. One trigger can send the same event to multiple platforms at once.

    **Perfect For:**

    * Tracking form completions and conversions
    * Sending leads to email marketing platforms
    * Measuring ad campaign performance
    * Recording user activity for product insights
    * Storing events in your own database

    **Supported Providers:**

    | Provider       | What it does                        | Setup needed                                  |
    | -------------- | ----------------------------------- | --------------------------------------------- |
    | **Klaviyo**    | Email marketing and automation      | API Key + user email                          |
    | **Meta Pixel** | Facebook/Instagram ad tracking      | Pixel ID + Access Token + user email and name |
    | **Amplitude**  | Product analytics and user behavior | API Key                                       |
    | **Database**   | Store events locally in Wizflow     | No setup needed                               |

    **How to Set It Up:**

    1. **Event Name** — Give your event a short, descriptive name (e.g. `lead_submitted`, `form_completed`)
    2. **Event Properties** *(optional)* — Add extra data like UTM source, campaign name, or any user answer
    3. **Providers** — Pick one or more platforms to send the event to and enter their credentials

    <Tip>
      You can send the same event to multiple providers at once — for example, track a lead in both Klaviyo and your database with a single trigger.
    </Tip>

    ```yaml theme={null}
    Example: Track a new lead across platforms
    - Event: "lead_submitted"
    - Properties: source (UTM), campaign name, lead value
    - Providers: Klaviyo (for email sequences) + Database (for internal reporting)
    ```

    <Info>
      **For developers:** Each provider returns its own success/failure status. The trigger output includes a `providers` array listing which providers succeeded and an `errors` object with details for any that failed.
    </Info>
  </Tab>

  <Tab title="UI Actions">
    **UI Action Trigger**

    Perform a visible action in the user's browser — redirect them to another page or show a popup message. Typically used at the end of a chatflow after other triggers (like email or webhook) have finished.

    **Perfect For:**

    * Redirecting users to a results or thank-you page
    * Showing a confirmation message after form submission
    * Navigating to an external site after data is processed
    * Displaying a summary or next-steps popup

    **Action Types:**

    | Action         | What it does                           | Fields                               |
    | -------------- | -------------------------------------- | ------------------------------------ |
    | **Redirect**   | Sends the user to a different web page | URL (can use dynamic values)         |
    | **Info Modal** | Shows a popup with a title and message | Title + content (supports rich text) |

    **How to Set It Up:**

    1. **Choose an action** — Redirect or Info Modal
    2. **Configure it:**
       * *Redirect:* Enter the URL to navigate to. You can use dynamic values from user answers or variables.
       * *Info Modal:* Write a title and message. The message supports rich text formatting.

    <Tip>
      UI Action triggers work best as the **last trigger** in a chain. For example: Webhook (send data) → Email (send confirmation) → UI Action (redirect to thank-you page).
    </Tip>

    ```yaml theme={null}
    Example: Redirect after submission
    - Action: Redirect
    - URL: "https://example.com/thank-you"

    Example: Show confirmation popup
    - Action: Info Modal
    - Title: "Application Received"
    - Content: "Thank you! We'll review your application and get back to you within 2 business days."
    ```

    <Info>
      **For developers:** The UI Action trigger has hidden metadata (pre-configured as instant/blocking). Its output mirrors the action type — a redirect returns the URL, and an info modal returns the title and description.
    </Info>
  </Tab>

  <Tab title="Data Management">
    **Manage Responses Trigger**

    Programmatically modify, update, or delete user responses during the chatflow for advanced data management.

    **Perfect For:**

    * Data cleanup and standardization
    * Response transformation and formatting
    * Conditional data management
    * Dynamic response updates based on calculations
    * Privacy compliance and data retention

    **Operations:**

    * **Upsert** - Create or update response values
    * **Delete** - Remove specific response data
    * **Transform** - Modify data format or structure
    * **Validate** - Ensure data quality and compliance

    ```yaml theme={null}
    Example: Standardize address format
    - Action: Upsert formatted address
    - Logic: Parse user input → Validate → Format
    - Output: Standardized address for downstream systems
    - Compliance: GDPR-compliant data handling
    ```
  </Tab>
</Tabs>

## Trigger Execution Options

<CardGroup cols={2}>
  <Card title="Instant/Blocking Execution" icon="bolt">
    **Immediate Processing**

    Execute triggers immediately and wait for completion before allowing users to proceed.

    * Best for: Critical calculations, validations, real-time processing
    * User Experience: Brief loading while trigger completes
    * Use Case: Financial calculations that affect next questions
  </Card>

  <Card title="Event-Based Execution" icon="calendar-clock">
    **Background Processing**

    Triggers execute in the background without interrupting user experience.

    * Best for: Notifications, data sync, non-critical processing
    * User Experience: Seamless flow continuation
    * Use Case: Email notifications, CRM updates, document generation
  </Card>
</CardGroup>

### Trigger Events

<Accordion title="Response Events">
  **When to Execute Triggers**

  * **On Create** - When user first provides a response
  * **On Update** - When user changes an existing response
  * **On Delete** - When response data is removed
  * **On All Events** - Execute on any response change

  *Choose the appropriate event based on your business logic needs*
</Accordion>

<Accordion title="Conditional Execution">
  **Smart Trigger Activation**

  Triggers can be enabled or disabled based on:

  * User response values
  * Calculated variables
  * External data conditions
  * Business rule requirements

  *Only execute triggers when conditions are met to optimize performance*
</Accordion>

## Real-World Implementation Examples

### Financial Services Workflow

<Steps>
  <Step title="Application Submission">
    User completes loan application chatflow with personal and financial information
  </Step>

  <Step title="Instant Risk Assessment">
    **Calculation Trigger** (blocking) performs real-time risk scoring and eligibility check
  </Step>

  <Step title="Document Generation">
    **PDF Trigger** generates personalized pre-approval letter or application summary
  </Step>

  <Step title="CRM Integration">
    **Webhook Trigger** creates lead record in Salesforce with risk score and documents
  </Step>

  <Step title="Team Notification">
    **Slack Trigger** alerts loan officers about high-value applications requiring review
  </Step>

  <Step title="Customer Communication">
    **Email Trigger** sends confirmation email with next steps and generated documents
  </Step>

  <Step title="Conversion Tracking">
    **Analytics Trigger** sends a "loan\_submitted" event to Klaviyo and Meta Pixel for marketing attribution
  </Step>

  <Step title="User Redirect">
    **UI Action Trigger** redirects the user to a personalized results page or shows a confirmation popup
  </Step>
</Steps>

### Insurance Onboarding Process

<CodeGroup>
  ```yaml Calculation Trigger theme={null}
  # Risk Assessment & Premium Calculation
  trigger: calculation
  input: age, health_data, coverage_amount, location
  processing: actuarial_risk_model
  output: 
    - premium_quote
    - risk_classification
    - coverage_recommendations
  ```

  ```yaml PDF Generation theme={null}
  # Policy Documents
  trigger: pdf_generation
  template: policy_agreement_template
  data: user_responses + calculation_results
  output: signed_policy_pdf
  attachments: terms_and_conditions
  ```

  ```yaml CRM Integration theme={null}
  # Customer Record Creation
  trigger: webhook
  method: POST
  endpoint: insurance_crm/create_policy
  payload:
    customer_data: user_responses
    premium: calculation_output.premium
    documents: pdf_trigger_output
  ```
</CodeGroup>

## Integration Capabilities

<CardGroup cols={3}>
  <Card title="Dynamic Content" icon="code">
    **Resource URIs**

    Reference user responses, variables, and other trigger outputs throughout your automation workflows.
  </Card>

  <Card title="Complex Transformations" icon="shuffle">
    **Business Logic**

    Apply sophisticated data transformations and business rules before sending to external systems.
  </Card>

  <Card title="Error Recovery" icon="arrows-rotate">
    **Reliability Features**

    Built-in retry logic, error reporting, and status tracking for mission-critical processes.
  </Card>
</CardGroup>

## Best Practices

### Performance Optimization

<Accordion title="Choose the Right Execution Type">
  **Blocking vs Background**

  * Use **blocking triggers** for calculations that affect subsequent questions
  * Use **background triggers** for notifications and non-critical integrations
  * Consider user experience impact when choosing execution timing
</Accordion>

<Accordion title="Optimize Trigger Chains">
  **Efficient Workflows**

  * Chain related triggers logically (calculation → document → notification)
  * Use conditional execution to avoid unnecessary processing
  * Consider API rate limits for external integrations
</Accordion>

### Error Handling

<Accordion title="Plan for Failures">
  **Robust Implementation**

  * Include fallback logic for external API failures
  * Implement appropriate timeout settings
  * Use status reporting to monitor trigger performance
  * Plan alternative flows when triggers fail
</Accordion>

<Accordion title="Data Validation">
  **Quality Assurance**

  * Validate data before sending to external systems
  * Use proper error messages for user feedback
  * Implement data sanitization for security
  * Test edge cases and boundary conditions
</Accordion>

## Security & Compliance

<Note>
  **Enterprise Security**

  Wizflow triggers support enterprise-grade security requirements:

  * **Encrypted Data Transfer** - All external communications use HTTPS/TLS
  * **Authentication Support** - Bearer tokens, API keys, OAuth integration
  * **Data Privacy** - GDPR-compliant data handling and retention
  * **Audit Trails** - Complete logging of trigger execution and data flow
  * **Access Controls** - Role-based permissions for trigger configuration
</Note>

<Warning>
  **Integration Considerations**

  When implementing triggers with external systems:

  * **Test thoroughly** in staging environments before production
  * **Monitor performance** and set appropriate timeouts
  * **Handle rate limits** for external APIs gracefully
  * **Secure credentials** using proper secret management
  * **Plan for downtime** of external services
</Warning>

***

## Related Features

<CardGroup cols={2}>
  <Card title="Variables" href="/features/variables">
    Create calculated values to use as trigger inputs and dynamic content
  </Card>

  <Card title="Conditional Logic" href="/features/conditional-logic-routing">
    Use conditional execution to trigger actions only when conditions are met
  </Card>

  <Card title="Entities Overview" href="/features/entities-overview">
    Understand the data sources available for trigger processing
  </Card>
</CardGroup>
