Add Slack feedback buttons for Duo agent responses

What does this MR do and why?

Relates to: #603660 (closed)

Adds thumbs up/down feedback buttons to Duo agent responses delivered in Slack, and records clicks as internal AI usage events. This implements steps 1 and 2 of the issue's sequencing (post buttons, handle clicks and tracking). The thumbs-down reason modal (step 3) is a follow-up.

Buttons appear on successful results only. Clicks are tracked as ai_duo_messaging_feedback_submitted and dual-written to the ai_usage_events Postgres and ClickHouse tables, flowing into the AI Impact dashboards. This mirrors the ai_duo_agentic_chat_feedback_submitted pattern.

Feedback data semantics: last-write-wins

Slack's feedback_buttons element is a toggle. Slack sends an interaction payload on every state change, with no deselection signal and no current-state field. One event is recorded per toggle, so a single user can produce multiple events for the same workflow, and a retracted feedback is invisible.

Since ai_usage_events is append-only, feedback is modelled as mutable state with last-write-wins semantics: the effective feedback for a user and workflow is the latest event. Consumers must not treat raw event counts as feedback counts (use argMax in ClickHouse or DISTINCT ON ... ORDER BY timestamp DESC in Postgres). This is documented in the event definition.

No new feature flag: the buttons ride along with the existing slack_duo_agent-gated flow, since they only render on messages that flow can produce.

How to set up and validate locally

  1. Set up the GDK Slack app integration and the Duo Slack agent flow (slack_duo_agent feature flag enabled, GitLab for Slack app installed, chat name linked).

  2. Mention the Duo bot in a Slack channel and wait for the run to complete.

  3. Verify the delivered result message carries Helpful / Not helpful feedback buttons.

  4. Click one and verify an ai_usage_events row is written:

    Ai::UsageEvent.where(event: 'ai_duo_messaging_feedback_submitted').last

    with extras containing feedback, workflow_id, and surface: slack.

  5. Verify a click from a Slack user without a linked GitLab account records nothing.

Screenshot
Screenshot_2026-07-10_at_13.10.54

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Thomas Schmidt

Merge request reports

Loading
Loading