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

# Two-Factor Authentication Integration

> Fetch 2FA codes from Gmail, Slack, and Twilio SMS for automations

Automatically fetch 2FA verification codes from email, Slack, or Twilio SMS messages—no manual code entry required.

> [!NOTE]
>
> For TOTP codes from authenticator apps, see [TOTP Integration](https://docs.optexity.com/docs/advanced/totp-integration.md).

## Methods

| Method | Source | Use Case |
| - | - | - |
| **Email** | Gmail inbox | Codes sent via email |
| **Slack** | Slack workspace | Codes sent via Slack |
| **SMS** | Twilio SMS | Codes sent via text |

All methods follow the same pattern:

1. Fetch messages from the source (email inbox, Slack channel, or Twilio SMS)
2. Extract the 2FA code from matching messages
3. Store the code in the specified `output_variable_name`
4. Use `{output_variable_name}` in subsequent actions to input the code

***

## Setup

1. Go to the [Optexity dashboard](https://app.optexity.com) → **Integrations**
2. Click the desired integration → **Connect**
3. Follow the prompts to grant access

### Twilio SMS

1. Log in to your Twilio account and open the Twilio Console
2. Go to **API Credentials** and copy your **Account SID** and **Auth Token**
3. Add or select a Twilio phone number that will send or receive verification texts
4. Connect the Twilio integration in Optexity using the same credentials and phone number

***

## Email 2FA

Fetch verification codes from email messages:

```json theme={null}
{
  "type": "action_node",
  "extraction_action": {
    "two_fa_action": {
      "action": {
        "type": "email_two_fa_action",
        "receiver_email_address": "user@example.com",
        "sender_email_address": "noreply@example.com",
        "integration_email_address": "automation-inbox@example.com"
      },
      "output_variable_name": "auth_code"
    }
  }
}
```

### Properties

| Property | Type | Required | Description |
| - | - | - | - |
| `receiver_email_address` | `str` | Yes | Recipient mailbox to search for 2FA emails |
| `sender_email_address` | `str` | Yes | Sender to filter (e.g., `noreply@site.com`) |
| `integration_email_address` | `str \| null` | No | Connected integration mailbox. Defaults to `receiver_email_address` if omitted |

> [!TIP]
>
> Use `integration_email_address` when the connected mailbox is different from the mailbox receiving the 2FA email (for example, alias/forwarding setups).

***

## Slack 2FA

Fetch verification codes from Slack messages:

```json theme={null}
{
  "type": "action_node",
  "extraction_action": {
    "two_fa_action": {
      "action": {
        "type": "slack_two_fa_action",
        "slack_workspace_domain": "mycompany.slack.com",
        "channel_name": "security-codes",
        "sender_name": "Security Bot"
      },
      "output_variable_name": "auth_code"
    }
  }
}
```

### Properties

| Property | Type | Required | Description |
| - | - | - | - |
| `slack_workspace_domain` | `str` | Yes | Workspace domain (identifies integration) |
| `channel_name` | `str` | Yes | Channel containing the 2FA messages |
| `sender_name` | `str` | Yes | Name of the bot/user sending the codes |

***

## SMS 2FA

Fetch verification codes from Twilio SMS messages:

```json theme={null}
{
  "type": "action_node",
  "extraction_action": {
    "two_fa_action": {
      "action": {
        "type": "sms_two_fa_action",
        "from_number": "+18777804236",
        "to_number": "+19897878948"
      },
      "output_variable_name": "auth_code"
    }
  },
  "before_sleep_time": 3,
  "end_sleep_time": 0
}
```

### Properties

| Property | Type | Required | Description |
| - | - | - | - |
| `from_number` | `str` | Yes | Twilio phone number sending the SMS code |
| `to_number` | `str` | Yes | Destination phone number receiving the SMS |

***

## Common Properties

These apply to Email, Slack, and SMS 2FA:

| Property | Type | Default | Description |
| - | - | - | - |
| `output_variable_name` | `str` | — | Variable name to store the extracted code |
| `instructions` | `str` | `None` | Optional custom instructions for code extraction |
| `max_wait_time` | `float` | `300.0` | Maximum wait time in seconds |
| `check_interval` | `float` | `10.0` | Polling interval in seconds |

> [!TIP]
>
> The action polls for the 2FA code every `check_interval` seconds until the code arrives or `max_wait_time` is reached.

***

## Using the Code

Reference the extracted code in subsequent actions:

```json theme={null}
{
  "type": "action_node",
  "interaction_action": {
    "input_text": {
      "command": "get_by_label(\"Verification Code\")",
      "input_text": "{auth_code[0]}"
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.