Tutorial: Get started with Slack - AWS Chatbot

Tutorial: Get started with Slack

To get started using AWS Chatbot to help manage your AWS infrastructure, follow the steps below to set up AWS Chatbot with chat rooms and Amazon SNS topic subscriptions.

Prerequisites

Before you get started, make sure you've completed the tasks in Setting up AWS Chatbot. You will need to choose a permissions scheme in the following procedure. This scheme determines the permissions your channel members will have and what AWS Chatbot can do on your behalf. For more information about AWS Chatbot permissions, see Understanding permissions. You must also create or choose a Slack channel to be used in your AWS Chatbot configuration. This channel is used to monitor and operate your AWS resources.

Step 1: Configure a Slack client

To allow AWS Chatbot to send notifications or run commands, you must configure AWS Chatbot with Slack. Workspace administrators must approve the use of the AWS Chatbot app in the workspace. Members can request to install apps if app approval is turned on by the workspace administrator. For more information, see Add apps to your Slack workspace.

To configure a Slack client
  1. Add AWS Chatbot to the Slack workspace:

    1. In Slack, on the left navigation pane, choose Automations.

      Note

      If you do not see Automations in the left navigation pane, choose More, then choose Automations.

    2. If AWS Chatbot is not listed, choose the Browse Apps Directory button.

    3. Browse the directory for the AWS Chatbot app and then choose Add to add AWS Chatbot to your workspace.

  2. Open the AWS Chatbot console at https://console.aws.amazon.com/chatbot/.

  3. Under Configure a chat client, choose Slack, then choose Configure.

    Note

    After choosing Configure, you'll be redirected to Slack's authorization page to request permission for AWS Chatbot to access your information. For more information, see Chat client application permissions for AWS Chatbot.

  4. From the dropdown list at the top right, choose the Slack workspace that you want to use with AWS Chatbot.

    There's no limit to the number of workspaces that you can set up for AWS Chatbot, but you can set up only one at a time.

  5. Choose Allow.

Step 2: Configure a Slack channel

To allow AWS Chatbot to send notifications or run commands in your Slack channel, you must also configure AWS Chatbot with a Slack channel. Configuring a channel consists of:

  • Adding AWS Chatbot to your Slack channel

  • Associating a channel with the configuration

  • Defining user permissions, which dictate what tasks users can perform in a channel

  • (Optional) Adding Amazon SNS topics, which AWS Chatbot uses to send notifications to your channel

To configure a Slack channel
  1. Add AWS Chatbot to the Slack channel:

    1. In your Slack channel, enter invite @aws.

    2. Choose Invite Them.

  2. Associate a channel with your configuration:

    1. On the Workspace details page in the AWS Chatbot console, choose Configure new channel.

    2. Under Configuration details, enter a name for your configuration. The name must be unique across your account and can't be edited later.

    3. If you want to enable logging for this configuration, choose Publish logs to Amazon CloudWatch Logs. For more information, see Amazon CloudWatch Logs for AWS Chatbot.

      Note

      There is an extra charge for using CloudWatch Logs.

    4. For Slack channel, choose the channel you used in step 1. AWS Chatbot supports both public and private channels.

      To configure a private channel with AWS Chatbot:

      1. In Slack, copy the Channel ID of the private channel by right-clicking on the channel name in the left pane and choosing Copy Link. The Channel ID is the string at the end of the URL (for example, AB3BBLZZ8YY).

      2. In AWS Chatbot, paste the ID into the Channel URL field. (If you copy the URL of the private Slack channel, the AWS Chatbot console shows only the Channel ID value when you paste it into the field.)

  3. Define user permissions:

    1. Choose your Role Setting.

      Tip

      Your role setting dictates what permissions your channel members have. A channel role gives all members the same permissions. This is useful if your channel members typically perform the same actions in Slack. A user role requires your channel members to choose their own roles. As such, different users in your channels can have different permissions. This is useful if your channel members are diverse or you don’t want new channel members to perform actions as soon as they join the channel. For more information, see Role setting.

      Channel role
      1. For Role setting, choose Channel role.

      2. For Channel role, choose Create new role. If you want to use an existing role instead, choose Use an existing role. To use an existing IAM role, you will need to modify it for use with AWS Chatbot. If you want your users to be able to use Amazon Q, attach the AmazonQDeveloperAccess policy. For more information, see Configuring an IAM Role for AWS Chatbot.

      3. For Role name, enter a name. Valid characters: a-z, A-Z, 0-9, .\w+=,.@-_.

      4. For Policy template, select Amazon Q permissions and any other templates you wish to use.

      User roles
      1. For Role setting, choose User roles.

    2. Select the policies that will make up your channel guardrails. Your channel guardrails control what actions are available to your channel members. Add the AmazonQDeveloperAccess policy as a channel guardrail to allow your users to use Amazon Q in your Slack channel.

  4. (Optional) Add Amazon SNS topics:

    Note

    If you want to receive notifications in your Slack channel, complete these steps.

    1. Choose your notification settings:

      1. For SNS Region, choose the AWS Region that hosts the SNS topics for this AWS Chatbot subscription.

      2. For SNS topic, choose the Amazon SNS topic for the client subscription. This topic determines the content that's sent to the Slack channel. If the region has additional SNS topics, you can choose them from the same dropdown list. The SNS topics you choose must be configured in the services for which you want to receive notifications. For more information, see Monitoring AWS services using AWS Chatbot.

      3. To add an Amazon SNS topic from another AWS Region to the notification subscription, choose Add another Region.

        Note

        For a tutorial on subscribing existing Amazon SNS topics to AWS Chatbot, see Tutorial: Subscribing an Amazon SNS topic to AWS Chatbot.

        Notifications from supported services that publish to the chosen Amazon SNS topics will now appear in the Slack channel.

  5. Choose Save.

Note

You can configure a Slack channel to run commands to your AWS account. For more information, see Running AWS CLI commands from chat channels.

You can configure as many channels with as many topics as you need.

If you want to allow AWS Chatbot to answer questions about your AWS resources, turn on AWS Resource Explorer in the Resource Explorer Console. For more information, see Getting started with Resource Explorer in the AWS Resource Explorer User Guide.

Step 3: Test notifications from AWS services to Slack

To verify that an Amazon Simple Notification Service (Amazon SNS) topic sends notifications to your Slack channel, you can test your setup by sending a notification. Ensure your AWS Chatbot configuration is subscribed to at least one Amazon SNS topic and that your topics are assigned to a service supported by AWS Chatbot. For a list of supported services, see Monitoring AWS services using AWS Chatbot. You can also test notifications by using CloudWatch. For more information, see Test notifications from AWS services to Amazon Chime or Slack using CloudWatch.

Testing notifications with configured clients
  1. Open the AWS Chatbot console.

  2. Choose the configured client you want to test.

  3. In the configured client, choose the channel to send a test notification to.

  4. Choose Send test message.

  5. View the confirmation message at the top of the screen that shows a message was sent to your Amazon SNS topic.

  6. Confirm the test message in your Slack channel.

Configuring Slack channels using AWS CloudFormation

You can automate Slack channel configuration by using an AWS CloudFormation template. To use an AWS CloudFormation template, you need the Workspace ID found under Workspace details in the AWS Chatbot console. For more information, see AWS::Chatbot::SlackChannelConfiguration in the AWS CloudFormation User Guide.

Next steps

After you configure your chat clients and test that your notifications are working, you might want to explore some of the following topics: