# Connect an alert destination

> Step by step: send a watch's alerts to Slack, Discord, Telegram, Home Assistant, IFTTT, Microsoft Teams, PagerDuty, SMS, WhatsApp or your own webhook. For the API and delivery details see [Integrations](/docs/integrations.md).

Every destination is connected the same way, by a person, on a page in Percia: open **Integrations**, press **Connect** on the service, finish the steps below, then pick the destination on a watch (or mark it as a **default** so every new watch uses it). An API key or an agent can start a connection and hand you the link, but only you can approve it. You can connect up to 20 destinations, and a watch can use up to 5.

If a destination stops working (a deleted channel, a revoked key) it shows **Needs attention**: connect the same destination again and Percia replaces the broken connection.

## Slack

1. Integrations, **Connect** on Slack.
2. Slack asks which workspace and channel Percia may post to. Pick them and choose **Allow**.
3. Back in Percia the connection shows as Active. Pick it on a watch.

Percia posts to that one channel only. To use another channel, connect again and pick it. If your workspace needs an admin to approve apps, ask them first.

## Discord

1. Integrations, **Connect** on Discord. Sign in to Discord if asked.
2. Discord shows a server and channel picker. Choose the server and channel and **Authorize**. Percia has no bot: Discord hands it a webhook for that channel.
3. The connection shows as Active.

You need the Manage Webhooks permission on that server.

## Telegram

1. Integrations, **Connect** on Telegram. Percia shows a button that opens the Percia bot in Telegram (`@percia_alerts_bot`).
2. In Telegram press **Start**. The bot says which Percia account the chat would receive alerts from, with the email partly hidden.
3. Press **Yes** if that is your account. **No** connects nothing. The connection shows as Active in Percia.

The bot only works in a private chat. Send `/stop` to it to disconnect that chat and `/help` for what it does.

## Home Assistant

1. In Home Assistant create an automation with the trigger **Webhook**. Copy its webhook URL, which looks like `https://<your-home-assistant>/api/webhook/<id>`.
2. The URL must be reachable over public https. If Home Assistant is only on your home network, use Home Assistant Cloud's webhook URL or your own secure public address.
3. In Percia: Integrations, **Connect** on Home Assistant, paste the URL, give it a label, **Connect**.
4. In the automation, read the payload as `trigger.json`: the goal, the reason, the time and `imageUrl`, as described in [Webhooks](/docs/webhooks.md).

The URL is the secret: anyone who has it can trigger the automation, so keep it private and replace it in Home Assistant if it leaks. Percia stores it sealed and never shows it again.

## IFTTT

1. In IFTTT open https://ifttt.com/maker_webhooks and choose **Connect**. Your Webhooks key is on the settings page https://ifttt.com/maker_webhooks/settings: it is the end of the URL shown there.
2. In IFTTT choose **Create**. **If This**: Webhooks, Receive a web request, event name `percia_goal_met` (letters, numbers and underscores only). **Then That**: Notifications from the IFTTT app, or any other action. In the message you can use `Value1` (the goal), `Value2` (the reason) and `Value3` (a link to the picture).
3. In Percia: Integrations, **Connect** on IFTTT, paste the key and the same event name, press **Connect**.

The IFTTT mobile app must be installed for the notification action. Percia stores the key sealed, never shows it again and sends it only to IFTTT.

## Microsoft Teams

1. In Teams open the **Workflows** app, choose **Create** and pick the template **Post to a channel when a webhook request is received** (or, in Power Automate, a flow whose trigger is **When a Teams webhook request is received**). Name it, pick the team and channel (or chat) to post to, and finish.
2. Open the flow's trigger and set **Who can trigger the flow** to **Anyone**, otherwise Teams answers 401 to Percia. Copy the **HTTP POST URL** (the webhook link). It contains `logic.azure.com` or `environment.api.powerplatform.com`.
3. In Percia: Integrations, **Connect** on Microsoft Teams, paste the link, give it a name, **Connect**, then pick it on a watch.

Addresses from the old Office 365 "Incoming Webhook" connector (`webhook.office.com`) no longer work in Teams, and Percia refuses them. The link is the secret: anyone who has it can post to that channel, so treat it like a password. Percia stores it sealed and never shows it again. If the flow is deleted or turned off, the destination shows **Needs attention**: make a new link (or turn the flow on) and connect again.

## PagerDuty

1. In PagerDuty open the service that should get the incidents (or create one), then **Integrations**, **Add an integration**, and choose **Events API v2**.
2. Copy the **Integration Key** (32 letters and digits).
3. In Percia: Integrations, **Connect** on PagerDuty, paste the key, choose a severity (`warning` by default), **Connect**, then pick it on a watch.

Each time a watch meets its goal Percia triggers an incident with the goal as its summary, the reason, a link to the event and the keyframe. It never resolves incidents: close them in PagerDuty. A repeated delivery of the same event does not open a second incident. Percia stores the key sealed and never shows it again. PagerDuty cannot tell Percia that a key was deleted (it still answers "accepted"), so if pages stop arriving, check the integration in PagerDuty and connect again.

## SMS and WhatsApp

You use your own Twilio account and pay Twilio for each message. A US phone number needs Twilio's A2P 10DLC registration to send SMS; a trial account reaches only numbers you have verified in Twilio.

1. In the Twilio Console copy your **Account SID** (starts with `AC`). Create an **API key** (Account, API keys & tokens) and copy its SID (`SK...`) and secret. This is recommended over your Auth Token because you can revoke it alone. Leaving the API key SID empty uses your Auth Token instead.
2. **SMS**: use a Twilio number (or a Messaging Service SID starting with `MG`) as the sender. **WhatsApp**: for a test, join Twilio's sandbox and use `+14155238886` as the sender. For your own sender, create a WhatsApp message template in Twilio (Content Template Builder), get it approved, and copy its **Content SID** (`HX...`): alerts arrive outside WhatsApp's 24-hour window, so only a template is accepted. Say which facts fill the template's `{{1}}`, `{{2}}`... (default `goal, reason, link`).
3. In Percia: Integrations, **Connect** on SMS or WhatsApp, enter the details and your phone number with the country code, choose how many messages an hour (20 by default), press **Connect**.

Percia stores everything sealed, shows your number masked and sends it only to Twilio. If the connection later needs attention, the page says why (for example you replied STOP to your Twilio number: reply START).

## Custom webhook

1. Have an https endpoint that accepts a `POST` with a JSON body.
2. In Percia: Integrations, **Connect** on Webhook, enter the URL and a label, **Connect**.
3. Percia shows a signing secret (`whsec_...`) **once**. Copy it now. Your endpoint uses it to check that a request is from Percia: see [Webhooks](/docs/webhooks.md) for the signature, the timestamp window and the body.

Deliveries are retried a few times when your endpoint fails, and are at least once, so deduplicate on the event `id`.

## After connecting

- **Pick it on a watch:** the watch's page, Alerts to, choose the destination. Or let an agent do it: "send this watch's alerts to Slack".
- **Make it a default:** switch on "Use for every new watch" and Percia attaches it to each new watch automatically.
- **Test it:** use the watch's test alert; the result shows as delivered or failed with the reason.
- **Remove it:** Integrations, the destination, **Remove**. Watches that used it keep running and stop posting there.
