feat: Slack notification on PR creation#1227
Conversation
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>
📝 WalkthroughWalkthroughWorkflow prompts were modified to require an explicit “plan” and to ask clarifying questions via Changes
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)
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
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>
There was a problem hiding this comment.
🧹 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 failedcurlwhenSLACK_WEBHOOK_URLis 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.numberblock (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
📒 Files selected for processing (1)
.github/workflows/amber-issue-handler.yml
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
.github/workflows/amber-issue-handler.yml
| 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. |
There was a problem hiding this comment.
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.
Summary
When the agent creates a PR from an issue (via
ambient-code:auto-fixlabel or@ambient-codeon an issue), it now sends a Slack notification with links to the PR and the session.Message format
Test plan
ambient-code:auto-fixto an issue — verify Slack notification sent after PR created@ambient-codeon an issue — verify same🤖 Generated with Claude Code
Summary by CodeRabbit