# How to Configure User Subscription to Notifications

According to messenger policies, bots cannot send messages first. For a user to receive notifications from the bot, they must first interact with the bot and send it any initial message.

---

## How Does Subscription Work?

1. User clicks a button on the website/in app "want to receive messages in messenger"
2. A link to the bot with parameters (deeplink) opens
3. User clicks "Start" in the messenger
4. Bot returns `chat_id` and `channel` back to the application through the `send_me` action
5. Now you can send notifications to the user via `call_node` API

---

## Creating Subscription Button

On the website/application side, create a button "want to receive messages in messenger" (or "track order status in messenger", "choose support channel", etc.).

In this button, the start parameter can contain:
- `customer_id` of the client in your CRM/ERP
- Order ID
- Other identification data

> 📖 **Documentation:** Read more about deeplink in [Launch scenario via deeplink](/en/integrations/explanation/deeplink-launch.md).

---

## Returning chat_id and channel

After the first message from the user (for example, clicking the "Start" button in Telegram), the bot should return back to the application (website, CRM, etc.) a pair of parameters:

- `chat_id` — unique chat ID within the messenger (usually an alphanumeric string)
- `channel` — channel name (telegram, viber, facebook, etc.)

In ConnectiveOne, there is a special `send_me` action for this.

---

## send_me Action Configuration

In this action settings, specify:

- `url` — address to send the request to
- `method` — request method (GET, POST)
- `data` — additional parameters to send, can contain placeholders, for example `{{messenger_input_param}}`
- `headers` — request headers

---

## Automatic Parameters

The `send_me` action automatically adds to request data:

- `chat_id` — user chat identifier
- `channel` — communication channel (telegram, viber, facebook, etc.)

These parameters don't need to be specified in configuration — they are added automatically.

---

## Configuration Example

```json
{
  "url": "https://your-crm.com/api/webhook/chat-registered",
  "method": "POST",
  "data": {
    "customer_id": "{{messenger_input_param}}",
    "user_name": "{{user_name}}"
  },
  "headers": {
    "Authorization": "Bearer YOUR_TOKEN",
    "Content-Type": "application/json"
  }
}
```

**Request result:**

```json
{
  "customer_id": "12345",
  "user_name": "Ivan",
  "chat_id": "398866372",
  "channel": "telegram"
}
```

---

## Possible Branching by Events

- `"ok"` — request successfully sent
- `"not_ok"` — error during request sending

---

## Error Handling

If the request ended with an error, the action returns `"not_ok"`. In the scenario, you can handle this event for:

- Retry
- Sending a message to the user
- Logging the error

---

## Sending Notifications After Subscription

After you receive `chat_id` and `channel`, you can send notifications to the user via `call_node` API.

> 📖 **Documentation:** Read more in [Launch scenario via API call_node](/en/integrations/how-to/launch-scenario-via-call-node.md).

---

## Limitations

- URL must be accessible from the ConnectiveOne server
- Only HTTP and HTTPS protocols are supported
- Request timeout depends on system settings

---

## Important Notes

> ⚠️ **Note:** When using Facebook, Viber deeplink, the `start` command is passed. Consider this if you use scenario branching with the `get_command` action.

If you don't need to use the user ID in the external system in the bot (for example, to identify), you can not pass any parameters, but simply send the user to the bot to do the first steps and save chat_id + channel in CRM/application.

---

## Related Articles

- [Launch scenario via deeplink](/en/integrations/explanation/deeplink-launch.md)
- [Launch scenario via API call_node](/en/integrations/how-to/launch-scenario-via-call-node.md)
- [What are integrations](/en/integrations/explanation/what-are-integrations.md)

