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

# Functions & Triggers

> App event triggers and custom functions for workflow automation.

Rilo supports app event triggers that automatically start workflows when events occur in connected services. Triggers enable event-driven automation without manual intervention.

## Overview

Functions & Triggers include:

* **App Event Triggers**: Start workflows on external service events
* **Custom Functions**: Tools and methods available from integrations
* **Trigger Types**: Manual, scheduled, and app event triggers

<Info>
  App event triggers enable true event-driven automation. Workflows start automatically when events occur, without manual triggers or schedules.
</Info>

## App Event Triggers

App event triggers start workflows when events occur in connected services.

### How App Event Triggers Work

1. **Connect Integration**: Connect to a service (e.g., Gmail, Slack)
2. **Configure Trigger**: Set up the app event trigger
3. **Wait for Event**: Workflow waits for the event
4. **Auto-Start**: Workflow starts automatically when event occurs

### Supported Trigger Events

Common app event triggers include:

<CardGroup cols={2}>
  <Card title="Gmail" icon="mail">
    * New email received
    * Email labeled
    * Email starred
  </Card>

  <Card title="Slack" icon="message-square">
    * New message
    * Channel created
    * User joined
  </Card>

  <Card title="GitHub" icon="github">
    * Pull request opened
    * Issue created
    * Push to repository
  </Card>

  <Card title="Salesforce" icon="database">
    * New lead created
    * Opportunity updated
    * Case created
  </Card>
</CardGroup>

### Example: Gmail Trigger

**Trigger Configuration:**

```json theme={null}
{
  "trigger_type": "app_event",
  "app_trigger_slug": "GMAIL_NEW_GMAIL_MESSAGE",
  "filters": {
    "from": "important@example.com"
  }
}
```

**Workflow Behavior:**

* Workflow starts automatically when new email arrives
* Email data is available in the Start block
* Workflow processes the email

<Info>
  App event triggers use exact trigger slugs from Composio. The AI agent researches available triggers when creating workflows.
</Info>

## Finding Available Triggers

### Via Capability Research

Ask Rilo about available triggers:

```
"What triggers are available for Gmail?"
```

Rilo will:

* Research available triggers
* List trigger options
* Show trigger slugs and descriptions

### Common Trigger Slugs

| Service | Trigger Slug                | Description            |
| ------- | --------------------------- | ---------------------- |
| Gmail   | `GMAIL_NEW_GMAIL_MESSAGE`   | New email received     |
| Slack   | `SLACK_RECEIVE_MESSAGE`     | New message in channel |
| GitHub  | `GITHUB_PULL_REQUEST_EVENT` | Pull request event     |
| GitHub  | `GITHUB_ISSUE_EVENT`        | Issue created/updated  |

<Info>
  Trigger slugs are automatically discovered by Rilo's AI when you describe what you want. You don't need to know the exact slug names.
</Info>

## Custom Functions

Custom functions are tools and methods available from integrations.

### Integration Functions

Each integration provides functions (tools) you can use:

**Gmail Functions:**

* `read_emails`: Read emails from inbox
* `send_email`: Send email
* `search_emails`: Search emails
* `create_label`: Create email label

**Slack Functions:**

* `send_message`: Send message to channel
* `create_channel`: Create new channel
* `get_messages`: Get channel messages
* `add_reaction`: Add reaction to message

### Using Functions in Workflows

Functions are used automatically when you describe what you want:

```
"Read unread emails from Gmail and send summary to Slack"
```

The AI agent:

* Identifies required functions
* Uses them in generated code
* Handles authentication automatically

### Function Discovery

Research available functions:

```
"What functions are available for Gmail?"
```

Rilo will:

* List all available functions
* Show function descriptions
* Provide usage examples

## Trigger Types

Rilo supports three trigger types:

### 1. Manual Trigger

Start workflows manually:

```json theme={null}
{
  "trigger_type": "manual"
}
```

**Use Case**: On-demand workflow execution

### 2. Scheduled Trigger

Run workflows on a schedule:

```json theme={null}
{
  "trigger_type": "scheduled",
  "schedule": "daily at 9 AM"
}
```

**Use Case**: Regular automated tasks

### 3. App Event Trigger

Start on external events:

```json theme={null}
{
  "trigger_type": "app_event",
  "app_trigger_slug": "GMAIL_NEW_GMAIL_MESSAGE"
}
```

**Use Case**: Event-driven automation

<Warning>
  Each workflow can have exactly **one** trigger type. You cannot combine trigger types (e.g., "daily at 9 AM OR when new email arrives"). Create separate workflows if you need multiple trigger types.
</Warning>

## Creating Triggers

### Via Natural Language

Describe the trigger:

```
"Start workflow when new email arrives from important@example.com"
```

The TriggerGeneratorAgent will:

* Identify trigger type
* Configure trigger settings
* Set up filters if needed

### Manual Configuration

Configure triggers in the workflow editor:

1. **Select Start Block**: Click on the start block
2. **Configure Trigger**: Choose trigger type
3. **Set Parameters**: Configure schedule or event
4. **Save**: Trigger is saved automatically

## Trigger Filters

App event triggers support filters to narrow down events:

### Gmail Filters

```json theme={null}
{
  "app_trigger_slug": "GMAIL_NEW_GMAIL_MESSAGE",
  "filters": {
    "from": "important@example.com",
    "subject_contains": "urgent"
  }
}
```

### Slack Filters

```json theme={null}
{
  "app_trigger_slug": "SLACK_RECEIVE_MESSAGE",
  "filters": {
    "channel": "#alerts",
    "mentions": "@here"
  }
}
```

<Info>
  Filters help reduce unnecessary workflow executions by only triggering on relevant events.
</Info>

## Best Practices

<AccordionGroup>
  <Accordion title="Use Appropriate Triggers">
    Choose the trigger type that best fits your use case. App events for real-time, scheduled for regular tasks.
  </Accordion>

  <Accordion title="Add Filters">
    Use filters to reduce unnecessary workflow executions and improve efficiency.
  </Accordion>

  <Accordion title="Test Triggers">
    Test triggers before deploying to production to ensure they work as expected.
  </Accordion>

  <Accordion title="Monitor Execution">
    Monitor workflow executions to ensure triggers are firing correctly.
  </Accordion>
</AccordionGroup>

## Limitations

### Trigger Limitations

* **Single trigger per workflow**: Each workflow has exactly one trigger
* **No trigger combinations**: Cannot combine multiple trigger types
* **Filter limitations**: Filters depend on service capabilities
* **Rate limits**: Subject to service rate limits

### Function Limitations

* **Integration-dependent**: Functions depend on connected integrations
* **OAuth scopes**: Limited to granted OAuth permissions
* **API rate limits**: Subject to service API limits
* **Service availability**: Depends on external service availability

<Warning>
  Understand trigger and function limitations to set appropriate expectations and design workflows accordingly.
</Warning>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Trigger not firing">
    * Verify integration is connected
    * Check trigger configuration is correct
    * Ensure trigger slug matches exactly
    * Review service logs for events
  </Accordion>

  <Accordion title="Too many triggers">
    * Add filters to narrow down events
    * Review trigger configuration
    * Check for duplicate workflows
  </Accordion>

  <Accordion title="Function not available">
    * Verify integration is connected
    * Check OAuth scopes include function
    * Ensure integration supports function
    * Research available functions
  </Accordion>
</AccordionGroup>

## Related Features

* [MCP Libraries](/integrations/mcp-libraries) - Custom tools via MCP
* [Custom Integrations](/integrations/custom-integrations) - Custom API functions
* [Integrations Overview](/features/integrations-overview) - General integration information

***

<Note>
  Functions and triggers are powerful automation tools. Use them to create event-driven workflows that respond to changes in your connected services.
</Note>
