On AWS Lambda, Welt serves Slack over HTTP: lambda_function.py is the handler, running on the Lambda Python runtime, and Slack sends events and button presses to its Function URL. template.yaml is an AWS SAM template that creates the function, its IAM role, and the Function URL.
The setup below assumes you already have an agent on AgentCore Runtime, a managed harness, or an agent served over HTTP elsewhere, such as on Lambda Web Functions, for the function to invoke.
-
Create a Slack app from
manifest.yml— the pre-filled creation screen is the quickest way there. Choose your workspace, then Next, Create and Install, and Allow. Two values come out of it; serving over HTTP needs no app-level token:- On the screen that says the app is ready, open Your app credentials and copy the Bot token (
xoxb-...). If you closed that screen, it is under Install App. - Choose Go to App Settings, and on the Basic Information page that opens, copy the Signing Secret.
- On the screen that says the app is ready, open Your app credentials and copy the Bot token (
-
Deploy using the release ZIP or build the function from source.
Release ZIP
Choose a tag with Lambda assets in GitHub Releases. Download the ZIP and its configured SAM template into the same directory, then deploy:
gh release download vX.Y.Z --repo iwamot/welt --pattern 'welt-lambda-*.zip' --pattern template.yaml sam deploy --template-file template.yaml --guidedTo update an existing function through the Lambda console, match its runtime, architecture, and handler to
WeltFunction.Propertiesin the same template, then upload the ZIP.Build from source
git clone https://github.com/iwamot/welt.git cd welt sam build sam deploy --guidedDuring
sam deploy --guided:- Set
SlackBotTokenandSlackSigningSecretfrom step 1, or store them in a Secrets Manager secret as the JSON keysSLACK_BOT_TOKENandSLACK_SIGNING_SECRETand setSlackSecretArnto its ARN instead. With the secret, the tokens stay out of the function's environment variables, as Lambda recommends, and the template lets the function read only that secret. Welt reuses the secret for five minutes, the default cache period of the AWS Parameters and Secrets Lambda Extension, so an edited secret takes effect within five minutes. For the agent, setAgentArnfor direct invocation, orAgentGatewayUrlandGatewayArnfor Gateway routing. Supplying all three uses the Runtime SDK through the Gateway. - Set the agent to invoke:
AgentArnfor a Runtime agent or harness,AgentGatewayUrlandGatewayArnfor a Gateway, orAgentUrlfor an agent served by URL, withAgentSigv4Service,AgentSigv4RegionandWebFunctionArnfor a Lambda Web Function. - Optionally, set
QueueArnto take requests from outside Slack from an SQS FIFO queue. - Answer
ytoAllow SAM CLI IAM role creation— the template creates the function's role. - Answer
ytoWeltFunction Function Url has no authentication. Is this okay?— it defaults to no, and Slack requests are verified with the signing secret instead. - Note the
FunctionUrlstack output; the next step needs it.
- Set
-
In the Slack app manifest, edit the
settings:section: add arequest_urlwith theFunctionUrloutput underevent_subscriptionsand again underinteractivity, so events and button presses arrive at the function, then setsocket_mode_enabledtofalse:settings: event_subscriptions: request_url: https://<url-id>.lambda-url.<region>.on.aws/ # the FunctionUrl output bot_events: - message.channels - message.groups - message.im - message.mpim interactivity: is_enabled: true request_url: https://<url-id>.lambda-url.<region>.on.aws/ # the same FunctionUrl socket_mode_enabled: false
After saving, Slack reports that the request URL isn't verified and offers to verify it; do so. The function answers Slack's challenge, which is why it is deployed before this step.
- Agent replies are bounded by Lambda's 15-minute cap, shorter than AgentCore Runtime's 60 minutes, and a reply that hits it is not retried. Deployment compares the limits on both sides.
- The optional variables in Configuration go under
Environment.Variablesintemplate.yaml. - To redeploy from source after a change, run
sam build && sam deploy. When using a release ZIP, repeat the release ZIP steps with the desired tag. sam deleteremoves everything the setup created.