Skip to content

feat: Slack notification on PR creation#1227

Merged
Gkrumbach07 merged 2 commits intomainfrom
feat/slack-on-pr-create
Apr 7, 2026
Merged

feat: Slack notification on PR creation#1227
Gkrumbach07 merged 2 commits intomainfrom
feat/slack-on-pr-create

Conversation

@Gkrumbach07
Copy link
Copy Markdown
Contributor

@Gkrumbach07 Gkrumbach07 commented Apr 6, 2026

Summary

When the agent creates a PR from an issue (via ambient-code:auto-fix label or @ambient-code on an issue), it now sends a Slack notification with links to the PR and the session.

Message format

PR created for #1234
PR: https://github.com/ambient-code/platform/pull/5678
Session: https://ambient.ai/projects/my-project/sessions/session-abc123

Test plan

  • Add ambient-code:auto-fix to an issue — verify Slack notification sent after PR created
  • @ambient-code on an issue — verify same

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated workflow logic to require creation of a plan and to prompt for clarification when ambiguous.
    • Added conditional Slack notifications: one before requesting user clarification and one after PR creation (sent only if configured).
    • Adjusted workflow step ordering and related guidance to reflect the new notification and clarification flow.

Fresh and fix-issue prompts now instruct the agent to send a Slack
notification immediately after creating the PR, with links to the
PR and the session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

Workflow prompts were modified to require an explicit “plan” and to ask clarifying questions via AskUserQuestion when ambiguous. Two conditional Slack webhook notifications were added: one immediately before AskUserQuestion (session streaming stops on that call) and one after PR creation; step numbering was adjusted accordingly.

Changes

Cohort / File(s) Summary
Workflow prompt & Slack notifications
.github/workflows/amber-issue-handler.yml
Changed AI prompts to require a “plan” and to call AskUserQuestion when ambiguity exists. Added conditional Slack webhook notifications sent (1) immediately before AskUserQuestion and (2) after PR creation (includes PR number and session URL). Notifications only run if SLACK_WEBHOOK_URL is set. Subsequent workflow step numbers were renumbered to reflect inserted steps.

Sequence Diagram(s)

sequenceDiagram
    participant Workflow as Workflow
    participant Session as Agentic Session
    participant Slack as Slack (Webhook)
    participant GitHub as GitHub (PR)
    participant User as User

    Workflow->>Session: start AI session (fresh prompt requires plan)
    Session->>Workflow: plan produced
    alt ambiguity detected
        Workflow->>Slack: send pre-AskUserQuestion notification (if SLACK_WEBHOOK_URL)\nrgba(37, 110, 239, 0.5)
        Workflow->>Session: AskUserQuestion (streaming stops)
        Session->>User: request clarification
        User->>Session: provide clarification
        Session->>Workflow: clarified response / updated plan
    end
    Workflow->>GitHub: create PR
    GitHub->>Workflow: PR created (number, URL)
    Workflow->>Slack: send post-PR notification with PR number + session URL (if SLACK_WEBHOOK_URL)\nrgba(16, 185, 129, 0.5)
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Security And Secret Handling ❌ Error Workflow uses literal <PR_URL> placeholder instead of actual PR URL substitution, creating functionality and potential security issues with malformed JSON payloads. Replace <PR_URL> placeholder with dynamic PR URL retrieval using 'gh pr view' command and ensure proper JSON escaping in curl payloads.
Title check ⚠️ Warning Title follows Conventional Commits format and is partially related to the changeset, but omits a significant aspect of the changes. Consider using a more comprehensive title that reflects both the planning phase introduction and Slack notifications, such as 'feat: Add planning phase and Slack notifications on PR creation'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Performance And Algorithmic Complexity ✅ Passed Workflow avoids algorithmic regressions: list ops bounded to 200 items, N+1 patterns eliminated via cached fields, API calls executed once per PR, polling capped at 60s. Additions are Slack notifications and instructional text only.
Kubernetes Resource Safety ✅ Passed PR modifies GitHub Actions workflow configuration, not Kubernetes resource manifests, so the Kubernetes Resource Safety check is not applicable.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/slack-on-pr-create
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/slack-on-pr-create

Comment @coderabbitai help to get the list of available commands and usage tips.

Fresh and fix-issue prompts now:
- Create a plan before implementing
- Ask for clarification on ambiguity via AskUserQuestion
- ALWAYS send Slack notification BEFORE calling AskUserQuestion
  (session stops streaming on AskUserQuestion, so notification
  must go out first or the user won't know to check)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.github/workflows/amber-issue-handler.yml (1)

93-99: Make the Slack step deterministic (real PR URL + explicit webhook guard).

Lines 93-99 and Lines 275-281 rely on <PR_URL> and a prose-only condition. This can yield placeholder text in Slack or a failed curl when SLACK_WEBHOOK_URL is unset.

Proposed prompt text update
-            6. After creating the PR, send a Slack notification:
+            6. After creating the PR, capture its URL in PR_URL and send a Slack notification only when webhook is configured:
                ```bash
-               curl -X POST -H 'Content-type: application/json' \
-                 --data '{"text":"PR created for #${{ steps.issue.outputs.number }}\n*PR*: <PR_URL>\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
-                 "$SLACK_WEBHOOK_URL"
+               if [ -n "$SLACK_WEBHOOK_URL" ]; then
+                 curl -sS -X POST -H 'Content-type: application/json' \
+                   --data '{"text":"PR created for #${{ steps.issue.outputs.number }}\n*PR*: '"$PR_URL"'\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
+                   "$SLACK_WEBHOOK_URL"
+               fi
                ```
-               Only send if SLACK_WEBHOOK_URL is set.
+               (`PR_URL` must be the actual URL of the PR you just created.)

Apply the same change pattern in the steps.context.outputs.number block (Lines 275-281).

Also applies to: 275-281

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/amber-issue-handler.yml around lines 93 - 99, The Slack
notification step currently uses the literal "<PR_URL>" and relies on prose to
guard against an empty webhook, which can send placeholders or fail; update the
step that posts after PR creation (referencing steps.issue.outputs.number) and
the similar steps.context.outputs.number block to (1) use the actual shell
variable $PR_URL instead of "<PR_URL>", (2) wrap the curl call in an explicit
guard like if [ -n "$SLACK_WEBHOOK_URL" ]; then ... fi, and (3) call curl with
-sS and proper headers so it fails noisily when invoked; ensure both occurrences
reference SLACK_WEBHOOK_URL and PR_URL exactly as variables so Slack receives
the real PR URL and the webhook is only used when set.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.github/workflows/amber-issue-handler.yml:
- Around line 93-99: The Slack notification step currently uses the literal
"<PR_URL>" and relies on prose to guard against an empty webhook, which can send
placeholders or fail; update the step that posts after PR creation (referencing
steps.issue.outputs.number) and the similar steps.context.outputs.number block
to (1) use the actual shell variable $PR_URL instead of "<PR_URL>", (2) wrap the
curl call in an explicit guard like if [ -n "$SLACK_WEBHOOK_URL" ]; then ... fi,
and (3) call curl with -sS and proper headers so it fails noisily when invoked;
ensure both occurrences reference SLACK_WEBHOOK_URL and PR_URL exactly as
variables so Slack receives the real PR URL and the webhook is only used when
set.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8353b936-a684-4c40-b5b9-5ba65a00b634

📥 Commits

Reviewing files that changed from the base of the PR and between 70171b4 and 87a54af.

📒 Files selected for processing (1)
  • .github/workflows/amber-issue-handler.yml

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/amber-issue-handler.yml:
- Around line 104-110: Replace the literal "<PR_URL>" in the Slack curl payloads
with the actual PR URL: when SLACK_WEBHOOK_URL is set, call gh pr view --repo
"${{ github.repository }}" --json url --jq '.url' to populate a PR_URL variable
and use that variable in the JSON payload instead of "<PR_URL>"; ensure both
occurrences that reference the created PR number (the blocks using ${{
steps.issue.outputs.number }} and ${{ steps.context.outputs.number }}) are
wrapped in an if [ -n "$SLACK_WEBHOOK_URL" ] check so the gh command and curl
only run when the webhook is configured.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 352c5b7a-5b2d-4e38-933b-ae2fee5494dd

📥 Commits

Reviewing files that changed from the base of the PR and between 87a54af and 41ce008.

📒 Files selected for processing (1)
  • .github/workflows/amber-issue-handler.yml

Comment on lines +104 to +110
7. After creating the PR, send a Slack notification:
```bash
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"PR created for #${{ steps.issue.outputs.number }}\n*PR*: <PR_URL>\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
"$SLACK_WEBHOOK_URL"
```
Only send if SLACK_WEBHOOK_URL is set.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use a real PR URL in Slack payloads (not <PR_URL>).

Line 107 and Line 300 currently use a literal placeholder, so the notification may not include a clickable PR link—the main feature this PR adds.

Suggested fix
-            7. After creating the PR, send a Slack notification:
+            7. After creating the PR, send a Slack notification:
                ```bash
-               curl -X POST -H 'Content-type: application/json' \
-                 --data '{"text":"PR created for #${{ steps.issue.outputs.number }}\n*PR*: <PR_URL>\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
-                 "$SLACK_WEBHOOK_URL"
+               if [ -n "$SLACK_WEBHOOK_URL" ]; then
+                 PR_URL=$(gh pr view --repo "${{ github.repository }}" --json url --jq '.url')
+                 curl -X POST -H 'Content-type: application/json' \
+                   --data '{"text":"PR created for #${{ steps.issue.outputs.number }}\n*PR*: '"$PR_URL"'\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
+                   "$SLACK_WEBHOOK_URL"
+               fi
                ```
-               Only send if SLACK_WEBHOOK_URL is set.
@@
-            7. After creating the PR, send a Slack notification:
+            7. After creating the PR, send a Slack notification:
                ```bash
-               curl -X POST -H 'Content-type: application/json' \
-                 --data '{"text":"PR created for #${{ steps.context.outputs.number }}\n*PR*: <PR_URL>\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
-                 "$SLACK_WEBHOOK_URL"
+               if [ -n "$SLACK_WEBHOOK_URL" ]; then
+                 PR_URL=$(gh pr view --repo "${{ github.repository }}" --json url --jq '.url')
+                 curl -X POST -H 'Content-type: application/json' \
+                   --data '{"text":"PR created for #${{ steps.context.outputs.number }}\n*PR*: '"$PR_URL"'\n*Session*: '"$PLATFORM_HOST/projects/$AGENTIC_SESSION_NAMESPACE/sessions/$AGENTIC_SESSION_NAME"'"}' \
+                   "$SLACK_WEBHOOK_URL"
+               fi
                ```
-               Only send if SLACK_WEBHOOK_URL is set.

Also applies to: 297-303

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/amber-issue-handler.yml around lines 104 - 110, Replace
the literal "<PR_URL>" in the Slack curl payloads with the actual PR URL: when
SLACK_WEBHOOK_URL is set, call gh pr view --repo "${{ github.repository }}"
--json url --jq '.url' to populate a PR_URL variable and use that variable in
the JSON payload instead of "<PR_URL>"; ensure both occurrences that reference
the created PR number (the blocks using ${{ steps.issue.outputs.number }} and
${{ steps.context.outputs.number }}) are wrapped in an if [ -n
"$SLACK_WEBHOOK_URL" ] check so the gh command and curl only run when the
webhook is configured.

@Gkrumbach07 Gkrumbach07 merged commit bcd258c into main Apr 7, 2026
13 checks passed
@Gkrumbach07 Gkrumbach07 deleted the feat/slack-on-pr-create branch April 7, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant