Buttons that prompt Slackbot
A button can carry an optional agent_prompt of up to 4000 Unicode code points.
Any app may set it. When Slackbot AI is available to the clicking user, Slack
sends the prompt to Slackbot; otherwise the button still sends an interaction
to your app. See Slack's button reference.
agent_prompt_display supplies the collapsed Slackbot message text and requires
agent_prompt. The complete prompt remains expandable. Omit the display to let
Slack use the button label. Slack documents no separate display length limit.
Neither field changes existing button placement or URL support.
These examples use native fields and set an action_id for routing the click.
An action ID remains optional in the payload schema. Add the resulting button
to an actions block or another supported button parent.
from slackblocks import Button
button = Button(
"Summarize", action_id="summarize_incident",
agent_prompt="Summarize this incident.", agent_prompt_display="Incident summary",
)
print(button)
import { Button } from "@nicklambourne/slackblocks";
const button = Button().text("Summarize").actionId("summarize_incident")
.agentPrompt("Summarize this incident.").agentPromptDisplay("Incident summary").build();
console.log(JSON.stringify(button));
package main
import (
"encoding/json"
"fmt"
slackblocks "github.com/nicklambourne/slackblocks/go/v3"
)
func main() {
button, err := slackblocks.NewButton().Text("Summarize").ActionID("summarize_incident").
AgentPrompt("Summarize this incident.").AgentPromptDisplay("Incident summary").Build()
if err != nil { panic(err) }
wire, err := json.Marshal(button)
if err != nil { panic(err) }
fmt.Println(string(wire))
}
import io.github.nicklambourne.slackblocks.element.ButtonElement;
class Example {
public static void main(String[] args) {
var button = ButtonElement.builder("Summarize", "summarize_incident")
.agentPrompt("Summarize this incident.").agentPromptDisplay("Incident summary").build();
System.out.println(button.toJson());
}
}
using Slackblocks.Elements;
var button = new ButtonElement("Summarize", "summarize_incident",
agentPrompt: "Summarize this incident.", agentPromptDisplay: "Incident summary");
System.Console.WriteLine(button.ToJson());
require "slackblocks"
button = Slackblocks::ButtonElement.new(
text: "Summarize", action_id: "summarize_incident",
agent_prompt: "Summarize this incident.", agent_prompt_display: "Incident summary"
)
puts button.to_json
use slackblocks::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let button = ButtonElement::builder().text("Summarize").action_id("summarize_incident")
.agent_prompt("Summarize this incident.").agent_prompt_display("Incident summary").build()?;
println!("{}", serde_json::to_string(&button)?);
Ok(())
}
<?php
require 'vendor/autoload.php';
$button = new Slackblocks\ButtonElement('Summarize', 'summarize_incident',
agentPrompt: 'Summarize this incident.', agentPromptDisplay: 'Incident summary');
echo $button->toJson();
button = Slackblocks.Elements.Button.new!(
text: "Summarize", action_id: "summarize_incident",
agent_prompt: "Summarize this incident.", agent_prompt_display: "Incident summary"
)
IO.puts(Slackblocks.encode!(button))
Always acknowledge the interaction
Your app receives a block_actions payload
in both cases, including when Slackbot receives the prompt. Verify the request
using your Slack framework's signature verification, route summarize_incident
to its handler, and acknowledge within three seconds before doing slow work.
Do not skip acknowledgement because the button contains a prompt, or assume
that an AI entitlement determines whether your handler runs. Follow Slack's
acknowledgement requirements.
Slackblocks constructs and validates the outgoing payload; your application owns the interaction handler. No new OAuth scope or live Slack request is needed to construct this button. AI availability and Slack's rendered behavior remain platform concerns. The library's deterministic tests cover payloads and validation, not live Slackbot acceptance.