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

# On Start Trip

## Overview

The **On Start Trip** automation event triggers when a field worker starts their trip using the MileApp Field mobile application. This event captures the moment when field operations begin, allowing you to automate workflows, send notifications, or integrate with external systems at the start of a trip.

## When Does This Event Trigger?

The "On Start Trip" event is triggered when:

1. They tap the "Start Trip" button
2. The trip start action is successfully recorded in the system

**Note:** This event is mobile-app specific and can only be triggered from the MileApp Field application, not from the web portal.

## Prerequisites

Before setting up an automation with this event, ensure:

1. You have access to the Automation feature in MileApp
2. You have appropriate permissions to create and manage automations
3. Field workers are using the MileApp Field mobile application
4. The "Start Trip - End Trip" feature is enabled in your organization settings

<Note>
  Required permission:

  * View Automation
  * Create Automation
</Note>

## Use Cases

### 1. Trip Start Notifications

**Scenario:** Operations team needs to be notified immediately when field workers begin their trips.

**Configuration:**

* **Event:** On Start Trip
* **Automation Type:** Webhook
* **Action:** Send notification to operations dashboard or messaging system

**Benefit:** Real-time visibility into field operations start times

### 2. Trip Logging and Tracking

**Scenario:** Company requires detailed trip logs for compliance and audit purposes.

**Configuration:**

* **Event:** On Start Trip
* **Automation Type:** Webhook
* **Action:** Log trip start data to external compliance system with timestamp, user, and location

**Benefit:** Automated compliance documentation without manual data entry

### 3. Checkpoint Task Creation

**Scenario:** Create initial checkpoint or preparation tasks when field work begins.

**Configuration:**

* **Event:** On Start Trip
* **Automation Type:** Create Task
* **Action:** Automatically create a vehicle inspection checklist task

**Benefit:** Ensures standard procedures are followed at trip start

### 4. External System Integration

**Scenario:** Synchronize trip start status with fleet management or dispatch system.

**Configuration:**

* **Event:** On Start Trip
* **Automation Type:** Webhook
* **Action:** Update field worker status to "Active" in external fleet management system

**Benefit:** Unified operational view across multiple systems

## Setting Up On Start Trip Automation

### Step 1: Navigate to Automation Settings

1. Log in to MileApp web portal
2. Click on **Flow** in the main navigation
3. Click on the **Automation** tab

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/jvVKvpPwiK1qABos/images/automation-tab.png?fit=max&auto=format&n=jvVKvpPwiK1qABos&q=85&s=b6493e509416761d04fe876351c975e3" alt="Automation Tab" width="600" data-path="images/automation-tab.png" />

  <p><i>Automation tab in Flow menu</i></p>
</div>

### Step 2: Create New Automation

1. Click the **New** button in the Automation page
2. The "Create Automation" dialog will appear

<div align="center">
  <img src="https://mintcdn.com/mileapp-c1584fbc/jvVKvpPwiK1qABos/images/automation-event.png?fit=max&auto=format&n=jvVKvpPwiK1qABos&q=85&s=b1cbf60faef178fd4e743c15cb7a2d93" alt="Create Automation Dialog" width="600" data-path="images/automation-event.png" />

  <p><i>Create Automation dialog with event selection showing all available automation events</i></p>
</div>

### Step 3: Configure Automation Details

Fill in the following information:

1. **Automation Name:** Provide a descriptive name (e.g., "Notify on Trip Start")

2. **Event:** Select **"On Start Trip"** from the dropdown

3. **Automation Type:** Choose the action type:
   * **Webhook** - Send data to external URL

4. Configure type-specific settings based on your chosen Automation Type

### Step 4: Configure Webhook (If Selected)

If you selected "Webhook" as the Automation Type:

1. **URL:** Enter the endpoint URL where trip start data should be sent
2. **Header (Optional):** Add custom HTTP headers if required (e.g., Authorization, Content-Type)
3. **Value (Optional):** Provide corresponding header values

**Example Webhook Configuration:**

```
URL: https://api.yourcompany.com/trip/start
Header: Authorization
Value: Bearer your_api_token_here
```

### Step 5: Save and Activate

1. Click **Submit** to create the automation
2. Ensure the automation is set to **Active** (toggle enabled)
3. Test the automation by having a field worker start a trip

## Webhook Payload Structure

When using the Webhook automation type with "On Start Trip", MileApp sends a POST request with the following data structure:

```json theme={null}
{
  "event": "on_start_trip",
  "timestamp": "2024-01-15T08:30:00.000Z",
  "user": {
    "id": "user_id_123",
    "name": "John Doe",
    "email": "john.doe@company.com",
    "phone": "+6281234567890"
  },
  "trip": {
    "startTime": "2024-01-15T08:30:00.000Z",
    "startLocation": {
      "latitude": -6.2088,
      "longitude": 106.8456,
      "address": "Jakarta, Indonesia"
    }
  },
  "hub": {
    "id": "hub_id_456",
    "name": "Jakarta Hub"
  }
}
```

**Note:** The exact payload structure may vary based on your MileApp configuration and version.

## Monitoring and Troubleshooting

### Viewing Automation Logs

To verify your "On Start Trip" automation is working correctly:

1. Go to **Flow > Automation**
2. Find your automation in the list
3. Click the **clock history** icon to view execution logs
4. Review successful executions and any errors

### Common Issues

**Issue:** Automation not triggering when trip starts

**Possible Causes:**

* Automation is not set to Active
* Field worker doesn't have proper permissions
* Start Trip feature is disabled in organization settings
* Network connectivity issues on mobile device

**Solution:**

* Verify automation is enabled (toggle is ON)
* Check user permissions in Settings > Permission
* Verify Start Trip feature is enabled in Settings > Organization
* Ensure field workers have stable internet connection

**Issue:** Webhook not receiving data

**Possible Causes:**

* Incorrect webhook URL
* Authentication headers missing or incorrect
* External endpoint is down or unreachable

**Solution:**

* Verify webhook URL is accessible
* Check authentication credentials
* Review automation logs for error details
* Test webhook endpoint independently

## Related Documentation

* [Automation Introduction](/pages/automation/introduction-to-automation)
* [Automation Type](/pages/automation/automation-type/introduction)
* [On Finish Trip](/pages/automation/automation-event/on-finish-trip)
* [Start Trip - End Trip Configuration](/pages/configuration/start-trip-end-trip)
* [Webhook Automation](/pages/automation/automation-type/webhook)

## Frequently Asked Questions

**Q: Does On Start Trip work with scheduled trips?**

A: Yes, the event triggers whenever a field worker manually starts a trip, regardless of whether it's a scheduled trip or an ad-hoc trip.

**Q: Can I set up multiple automations with On Start Trip event?**

A: Yes, you can create multiple automations for the same event. Each will execute independently when the event is triggered.

**Q: What happens if the webhook endpoint is temporarily unavailable?**

A: MileApp will attempt to retry the webhook request a limited number of times. Check the automation logs to see retry attempts and final status.

**Q: Is there a delay between trip start and automation trigger?**

A: The automation typically triggers within seconds of the trip start action. Actual timing may vary based on network conditions and system load.
