Connect Bedrock Agent(s) to a Slack bot

Describe the problem/error/question

Hi all, I have multiple Bedrock Agents that I built that I want to connect to a Slack bot and call them via slash commands. How can I do that?

Hey, you need to figure out two main parts: how to route Slack commands to n8n and how to call your agents on Bedrock.

Slack setup

  • You need to create a Slack app and configure it to send slash command data to an n8n webhook
  • Go to Slack API: Applications | Slack and sign in
  • Click on “Create an App” => “From scratch”
  • Go to Slash Commands under the “Features” sections
    • “Create New Command”
    • Request URL: this should be a webhook in a new n8n workflow that you create
  • Under “Settings” click on “Install App”
    • you may need to get approval to install it in your workspace
  • Now in Slack go to a channel where you want to test the slash commands
    • in the field to write a message type “/invite” and select “Add apps to this channel”
    • select your newly created Slack app
    • now you should be able to use the slash commands in the channel, but you will likely get an error - to fully test this go to your n8n workflow with the webhook and click on “Listen for test event”
    • now the slash command should start the workflow

Call Bedrock

  • as of now there’s no existing node to call Bedrock agents from n8n, so you need to use the REST API
  • go to your n8n workflow and after the webhook node add a HTTP Request node
  • I’m not very familiar with Bedrock, but I think this is the API endpoint to call an agent: InvokeAgent - Amazon Bedrock
  • the API seems quite complicated to use, so you could also consider to implement your agents directly in n8n - it’s super easy and powerful! You can still use models from Bedrock in the Agent node

Once you have the basic setup running you can improve things, like adding a Switch node in n8n to distinguish which Slack slash command was sent (you can figure it out by the payload that the webhook receives from Slack).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.