> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.swellsystem.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Form Integrations

# Form Integrations

Connect your forms to other modules to automate workflows and data entry.

## Available Integrations

### CRM Integrations

#### Create Contact
Automatically create or update contacts from form submissions.

**Configuration:**
- Map form fields to contact fields:
  - `first_name` → Form field
  - `last_name` → Form field
  - `email` → Form field
  - `phone` → Form field
  - `company_id` → Lookup or create company

**Options:**
- Create new contact or update existing (by email)
- Link to existing company or create new
- Add tags to contact
- Assign to user/team

**Example:**
```
Form Field: "Email" → Contact Field: "email"
Form Field: "First Name" → Contact Field: "first_name"
Form Field: "Last Name" → Contact Field: "last_name"
```

#### Create Company
Automatically create or update companies from form submissions.

**Configuration:**
- Map form fields to company fields:
  - `name` → Form field
  - `email` → Form field
  - `phone` → Form field
  - `website` → Form field
  - `address` → Form field

**Options:**
- Create new company or update existing (by name/email)
- Link contacts to company
- Add tags to company
- Trigger company enrichment (if website provided)

#### Create Lead
Convert form submissions to leads in your CRM.

**Configuration:**
- Map form fields to lead fields:
  - `title` → Form field or auto-generated
  - `value` → Form field or default
  - `status_id` → Default status
  - `source_id` → "Form: [Form Name]"
  - `description` → Form field or concatenated answers

**Options:**
- Auto-assign based on rules
- Set lead value from form field
- Add tags to lead
- Link to contact/company

### Support Integration

#### Create Support Ticket
Generate support tickets from form submissions.

**Configuration:**
- Map form fields to ticket fields:
  - `subject` → Form field or auto-generated
  - `body` → Form field or formatted submission
  - `inbox_id` → Default inbox
  - `priority` → Default or form field
  - `type` → Default or form field

**Options:**
- Auto-assign to agent
- Set priority based on form field
- Include form submission as ticket message
- Link to contact/company

### Email Marketing Integration

#### Subscribe to Email List
Add form submissions to email marketing lists.

**Configuration:**
- Select email list(s)
- Map form fields:
  - `email` → Form field (required)
  - `first_name` → Form field (optional)
  - `last_name` → Form field (optional)

**Options:**
- Subscribe to multiple lists
- Double opt-in (send confirmation email)
- Update existing subscription
- Add tags to contact
- Respect unsubscribe preferences

### Custom Integrations

#### Webhook
Send form data to external systems via webhook.

**Configuration:**
- **Webhook URL**: Endpoint to send data to
- **HTTP Method**: POST, PUT, PATCH
- **Headers**: Custom headers to include
- **Payload Mapping**: Map form fields to payload
- **Retry Logic**: Configure retry attempts

**Example Payload:**
```json
{
  "form_id": 123,
  "submission_token": "abc123",
  "data": {
    "name": "John Doe",
    "email": "john@example.com"
  }
}
```

#### Email Notification
Send email notifications when forms are submitted.

**Configuration:**
- **Recipients**: Email addresses to notify
- **Subject**: Email subject line
- **Template**: Email template (optional)
- **Include Submission Data**: Include form data in email

**Options:**
- Multiple recipients
- Custom email template
- Conditional sending

#### Redirect
Redirect users after form submission.

**Configuration:**
- **Redirect URL**: Where to redirect
- **Query Parameters**: Add form data to URL
- **Conditional Redirects**: Redirect based on answers

**Example:**
```
Redirect URL: /thank-you?name={{name}}&email={{email}}
```

## Setting Up Integrations

### Step 1: Add Integration

1. Open form in builder
2. Go to **Integrations** tab
3. Click **"Add Integration"**
4. Select integration type

### Step 2: Configure Integration

1. **Name**: Give integration a name
2. **Field Mapping**: Map form fields to integration fields
3. **Conditions**: Set when integration should execute
4. **Order**: Set execution order (if multiple integrations)

### Step 3: Test Integration

1. Save form
2. Submit test submission
3. Check integration results:
   - View in submission details
   - Check CRM/Support/Email for created records
   - Review integration logs

## Conditional Integrations

Set conditions for when integrations should execute:

**Example Conditions:**
```
IF "How did you hear about us?" EQUALS "Referral"
THEN Execute "Create Lead" integration
ELSE Skip integration
```

**Condition Operators:**
- Equals (=)
- Not Equals (≠)
- Contains
- Greater Than (>)
- Less Than (<)
- Is Empty
- Is Not Empty

## Multiple Integrations

You can add multiple integrations to a single form:

1. **Execution Order**: Set order of execution
2. **Independent Execution**: Each integration runs independently
3. **Error Handling**: If one fails, others still execute
4. **Results Tracking**: View results for each integration

## Integration Results

View integration results in submission details:

- **Success/Failure**: Status of each integration
- **Created Records**: IDs of created contacts, companies, leads, tickets
- **Error Messages**: If integration failed
- **Execution Time**: How long integration took

## Best Practices

1. **Test First**: Test integrations with test submissions
2. **Field Mapping**: Ensure field mappings are correct
3. **Error Handling**: Set up error notifications
4. **Conditional Logic**: Use conditions to avoid unnecessary integrations
5. **Data Validation**: Ensure form data is valid before integration
6. **Monitor Results**: Regularly check integration success rates

## Troubleshooting

### Integration Not Executing
- Check integration is active
- Verify conditions are met
- Review integration logs

### Integration Failing
- Check field mappings
- Verify integration configuration
- Review error messages in submission details

### Duplicate Records
- Check "Update Existing" option
- Verify matching criteria (email, name, etc.)
- Review integration conditions