以下の内容はhttps://blog.systemjp.net/entry/2026/03/13/141800より取得しました。


codex で 実行終わったらslackに通知させる方法(windows)

※まだ処理途中でも通知来ることあるな・・・

C:\Users\<ユーザー名>\.codex\notify-slack.ps1を作成。UTF8のBOM付で保存

param(
    [string]$payloadJson
)

$logFile = "C:\Users\<ユーザー名>\.codex\notify-slack.log"
$webhookUrl = "https://hooks.slack.com/services/XXXX/XXXX/XXXX"

Add-Content -Path $logFile -Value "---- $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') ----"
Add-Content -Path $logFile -Value "RAW: $payloadJson"

try {
    $payload = $payloadJson | ConvertFrom-Json

    if ($payload.type -ne "agent-turn-complete") {
        Add-Content -Path $logFile -Value "SKIP: not agent-turn-complete"
        exit 0
    }

    $lastMessage = $payload.'last-assistant-message'
    if ([string]::IsNullOrWhiteSpace($lastMessage)) {
        $lastMessage = "Codex の処理が完了しました"
    }

    if ($lastMessage.Length -gt 200) {
        $lastMessage = $lastMessage.Substring(0, 200) + "..."
    }

    $text = "Codex 完了`n$lastMessage"

    $json = @{
        text = $text
    } | ConvertTo-Json -Compress -Depth 5

    $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($json)

    Invoke-RestMethod `
        -Uri $webhookUrl `
        -Method Post `
        -ContentType "application/json; charset=utf-8" `
        -Body $bodyBytes | Out-Null

    Add-Content -Path $logFile -Value "POST OK"
}
catch {
    Add-Content -Path $logFile -Value ("ERROR: " + $_.Exception.Message)
    throw
}

C:\Users\<ユーザー名>\.codex\config.tomlに以下を追加

上の方

...
notify = [
  "powershell",
  "-NoProfile",
  "-ExecutionPolicy", "Bypass",
  "-File", "C:\\Users\\<ユーザー名>\\.codex\\notify-slack.ps1"
]
v

[tui]のところ

[tui]
notifications = true
notification_method = "auto"
...



以上の内容はhttps://blog.systemjp.net/entry/2026/03/13/141800より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14