# Launch Scenario via Deeplink

Deeplink allows creating direct links for launching bot scenarios with parameters. This is useful for creating personalized links from advertising campaigns, passing client ID or order ID, or tracking traffic sources.

---

## What is deeplink?

In messengers, there are mechanisms that allow passing input parameters to a bot. These mechanisms are called **deeplink** and represent a way to embed a parameter in a link that will open the bot.

> 📖 **Documentation:** Read more about deeplink in official messenger documentation:
> - [Viber Deep Links](https://developers.viber.com/docs/tools/deep-links/)
> - [Telegram Deep Linking](https://core.telegram.org/bots#deep-linking)

---

## When to Use Deeplink?

Deeplink is suitable for such cases:

- Launching a scenario from an advertising campaign with unique parameters
- Passing client ID or order ID through a link
- Creating personalized links for different user groups
- Tracking traffic source (UTM tags)

---

## Deeplink Formats for Different Messengers

### Telegram

**Format:**

```
https://telegram.me/<Bot_Name>?start=<UserID>
```

**Example:**

```
https://telegram.me/mybot?start=12345
```

**Limitations:**
- Limit for start parameter: **64 characters**
- For subscribing to notifications, clicking the link is not enough, you need to press the **"Start"** button

### Viber

**Format:**

```
viber://pa?chatURI=<URI>&context=<UserID>&text=<Start!>
```

**Example:**

```
viber://pa?chatURI=mybot&context=12345&text=Start!
```

**Parameters:**
- `chatURI` — your bot's URI in Viber
- `context` — context (parameter that will be passed to the bot)
- `text` — text that will be inserted into the user's input line (optional)

> ℹ️ **Note:** If the `text` parameter is not passed, clicking the link will still be considered the start of the conversation and sufficient for subscribing to notifications.

### Facebook Messenger

When using deeplink, the `start` command is passed. Consider this if you use scenario branching with the `get_command` action.

---

## Launch Scenario via Entry Point Deeplink URL

In any **entry point** (Entry Point), there is a URL that can be copied to launch the scenario from that point. This is available for:

- Telegram
- Viber

> 💡 **Note:** If you don't see the URL, check if the channel is connected to the bot.

**Example URL:**

```
https://t.me/botname/?start=n__3
```

Clicking this link will launch the bot from the specified entry point.

---

## Processing Start Parameter in Scenario

If you want to use the start parameter in the scenario, use the `get_command` action.

**How it works:**

1. The `get_command` action processes commands like `/commandname` or passed via deeplink
2. If a parameter is passed, sets the constant `{{messenger_input_param}}`
3. Then you need to parse `messenger_input_param` as convenient through the scenario

**Processing example:**

```javascript
// In action jail or through if_else
const param = j.messenger_input_param || '';

if (param === '12345') {
  return 'customer_12345';
} else if (param.startsWith('order_')) {
  return 'order_tracking';
}

return 'default';
```

---

## Usage Examples

### Example 1: Passing Client ID

**Creating link:**

```
https://t.me/mybot?start=customer_12345
```

**Processing in scenario:**

Use `{{messenger_input_param}}` to get the client ID and further processing.

### Example 2: Passing Order ID

**Creating link:**

```
https://t.me/mybot?start=order_67890
```

**Processing in scenario:**

Use `{{messenger_input_param}}` to get the order ID and further processing.

---

## Limitations

### Telegram

- Maximum start parameter length: 64 characters
- Need to press the "Start" button to subscribe to notifications
- Parameter is passed as `/start <parameter>`

### Viber

- The `text` parameter is optional
- Clicking the link is sufficient for subscribing to notifications
- Parameter is passed through `context`

### Facebook Messenger

- When using deeplink, the `start` command is passed
- Consider this if you use scenario branching with the `get_command` action

---

## Related Articles

- [Subscribe user to notifications](/en/integrations/how-to/data-transfer/subscribe-user-to-notifications.md)
- [Launch scenario via API call_node](/en/integrations/how-to/launch-scenario-via-call-node.md)
- [UTM tags transfer](/en/integrations/explanation/utm-tags-transfer.md)
- [What are integrations](/en/integrations/explanation/what-are-integrations.md)
- [Viber Deep Links Documentation](https://developers.viber.com/docs/tools/deep-links/)
- [Telegram Deep Linking Documentation](https://core.telegram.org/bots#deep-linking)

