# Opik experiment finished notifications on your phone

> Get a push notification with the feedback scores when an Opik experiment finishes.

- Company: Opik (https://www.justpush.io/recipes/opik)
- Event: `experiment:finished` (Experiment finished)
- Tags: AI, Monitoring
- Install: https://studio.justpush.io/recipes/opik/experiment-finished
- Web page: https://www.justpush.io/recipes/opik/experiment-finished

## Setup

1. Click Install in Studio and sign in. The recipe is added to your account and you get a personal webhook URL.
2. In Opik, open Production > Alerts and create an alert with destination type General.
3. Paste your webhook URL (shown in Studio after install) as the webhook URL and select the Experiment finished events.
4. Use Test trigger to send the example payload, then save.
5. In Opik, open **Production → Alerts**, create an alert with destination type **General**, paste the URL above, and select the `experiment:finished` event. Experiment events are workspace-wide.
6. Opik can send a secret token as `Authorization: Bearer …`, but JustPush doesn't check it yet, so keep your endpoint URL private.

## Code

Studio calls `handleRequest(request)` with the incoming webhook (`{ method, headers, body, query, raw }`) and sends the message object it returns. Returning `null` sends nothing.

```js
// Opik → experiment finished
// Fires when an Opik experiment completes, if an alert with a General webhook destination
// subscribes to "experiment:finished". Shows the experiment's feedback scores.
// Docs: https://www.comet.com/docs/opik/production/alerts

function handleRequest(request) {
    const body = request.body || {}

    // Guard: only experiment:finished events.
    if (body.eventType !== "experiment:finished") {
        console.log(`Ignoring Opik "${body.eventType ?? "unknown"}" webhook`)
        return null
    }

    const meta = body.payload?.metadata
    const experiments = Array.isArray(meta) ? meta : meta ? [meta] : []
    const first = experiments[0] ?? {}
    const scores = Array.isArray(first.feedback_scores)
        ? first.feedback_scores
              .filter((score) => score?.name && Number.isFinite(Number(score.value)))
              .slice(0, 4)
              .map((score) => `${score.name} ${Math.round(Number(score.value) * 100) / 100}`)
        : []
    const more = experiments.length > 1 ? ` (+${experiments.length - 1} more)` : ""

    return {
        title: `🧪 Experiment finished${first.name ? `: ${first.name}` : ""}`,
        message: (scores.join(" · ") || "No feedback scores yet") + more,
        topic: "Opik",
        priority: -1, // Low — results are ready whenever you are
    }
}
```

## Opik experiment:finished webhook payload (sample)

```json
{
  "id": "webhook-event-8a4b",
  "alertId": "1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
  "payload": {
    "metadata": [
      {
        "id": "exp-uuid",
        "name": "gpt-4.1-vs-baseline",
        "created_by": "jane@example.com",
        "dataset_id": "dataset-uuid",
        "feedback_scores": [
          {
            "name": "accuracy",
            "value": 0.92
          },
          {
            "name": "hallucination",
            "value": 0.034
          }
        ]
      }
    ],
    "alertName": "Experiments",
    "eventType": "experiment:finished",
    "eventCount": 1
  },
  "alertName": "Experiments",
  "createdAt": "2026-09-29T10:30:00Z",
  "eventType": "experiment:finished",
  "workspaceId": "workspace-uuid"
}
```

## FAQ

### Does this work on iPhone and Android?

Yes. Install the JustPush app from the App Store or Google Play and sign in. Every phone signed in to your account gets the notification.

### Do I need to write code?

No. Install the recipe in Studio, paste your webhook URL into Opik and you are done. The code is there if you want to change the text, the sound or the buttons.

### Can I change what the notification says?

Yes. After install the recipe's code is yours. Edit it in Studio and test it against the sample payload before you save.

### What does it cost?

JustPush is free for 30 days. After that it's $19.99 a year, or $39.99 once. There is no extra charge for recipes.
