← All recipes

GitHub Actions recipe · Works on every plan

Auto-close and block high-confidence spam

Scitor scores every inbound email for spam using the email provider's own score — not AI, so this works on the Free plan too. When a message lands as spam:high, this workflow blocks the sender and closes the ticket automatically.

What this workflow does

It fires on spam:high, posts a /block-sender comment (a real Scitor slash command that silently drops future emails from that sender), and closes the issue.

What it does not do

It only acts on spam:high — lower-confidence scores (spam:medium, spam:low) are left for a human. It doesn't undo a block — if Scitor's scoring is ever wrong, run /unblock-sender yourself on the issue.

The workflow file

Save as .github/workflows/auto-close-spam.yml.

# Auto-close and block high-confidence spam
#
# Scitor scores every inbound email for spam and applies a `spam:*` label
# — this comes from the email provider's own spam score, not AI, so it
# works on every plan including Free. This closes the ticket and blocks
# the sender the moment Scitor flags one as high-confidence spam.
#
# What this does:
#   - Fires when Scitor applies `spam:high`.
#   - Posts a `/block-sender` comment, which Scitor reads as a command to
#     silently drop future emails from that sender.
#   - Closes the issue with reason "not planned".
#
# What this does NOT do:
#   - It only acts on `spam:high`. Lower-confidence scores (`spam:medium`,
#     `spam:low`) are left for a human to review — change the `if:`
#     condition below if you want to auto-close those too.
#   - It does not undo a block: if Scitor's spam scoring is ever wrong,
#     you'll need to run `/unblock-sender` on the issue yourself.
#
# No secrets required — uses the workflow's default GITHUB_TOKEN, and
# `/block-sender` is a Scitor slash command, not a GitHub API call.
#
# Source: adapted from Scitor's own documented example at
# https://support.scitor.io/guides/github-actions#auto-block-spam-and-close

name: Auto-close high-confidence spam
on:
  issues:
    types: [labeled]

jobs:
  block-and-close:
    if: >
      github.event.label.name == 'spam:high' &&
      github.event.issue.user.login == 'scitor-customerops[bot]'
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: '/block-sender',
            });

            await github.rest.issues.update({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              state: 'closed',
              state_reason: 'not_planned',
            });

No secrets required — uses the workflow's default token and Scitor's own slash command.

Let spam close itself

Takes under 5 minutes. Free tier available. No credit card required.