Bhargavi Chinnappa
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ## Slack Slack is a collaboration platform that is used by organizations to facilitate communication among team members. The team members can have conversations, share files, images, video, audio, and schedule meetings. It also provides a secure, collaborative environment for teams to work together by using chat, video meetings, file storage, and application integration. ### Supported slack features Yellow.ai supports the following slack features: | Feature | Supported? | | -------------------- | ---------- | | Two-way conversation | yes | | Outbound messaging | no | | Interactive Features | no | | Slash Commands/Shortcuts| yes | | Ephemeral Message| no | | V2 Notification API| no | In this article, you will learn: * [How to create an app on Slack](#2-create-an-app) * [How to configure a workspace](#3-configure-singlemulti-workspace) * [How to add Slack to Direct message/Channel](#4-adding-slack-app-to-direct-messagechannel) * [How to test the bot on Slack](#test) * [Slack APIs integration](#5-api) * [Slack features supported by yellow.ai](#6-supported-slack-features) ## Create an app in Slack You need to create an app in Slack to connect your bot using the following procedure. To create an app in Slack, follow these steps: 1. Go to the [Slack website](https://api.slack.com/apps) and click **Create an App** > select **From scratch**. ![](https://i.imgur.com/gdiyQT4.png) 2. Enter the app name and select an app development workspace, then click **Create App**. <img src="https://i.imgur.com/VB59aXm.png)" alt="drawing" width="60%"/> ### Step 1: Add a new redirect URL After creating an app, you need to add a redirect URL. To add a new redirect URL, follow these steps: 1. Select **OAuth & Permissions**. ![](https://i.imgur.com/UFL2MGQ.png) 2. Under *Redirect URLs*, click **Add a new Redirect URL**. ![](https://i.imgur.com/ZHKe9cn.png) 3. Enter the `https://cloud.yellow.ai/integrations/oauth/redirect` redirect URLs and click **Add**. For more details, see [Scope references](https://api.slack.com/scopes). <img src="https://i.imgur.com/BKDcxn7.png)" alt="drawing" width="60%"/> 4. Click **Save URLs**. 5. Under the *Scope* section, add the **Bot Token Scope** according to your requirements. - **Required Bot Token Scopes:** - [channels:history](https://api.slack.com/scopes/channels:history)- View messages and other content in public channels to which the app has been added. - [app_mentions:read](https://api.slack.com/scopes/app_mentions:read)- View messages that directly mention the @Yellow test bot in conversations that the app is in. - [chat:write ](https://api.slack.com/scopes/chat:write)- Send messages as @yourBot. - [commands](https://api.slack.com/scopes/commands)- Add shortcuts and/or slash commands that people can use. - [groups:history](https://api.slack.com/scopes/groups:history)- View messages and other content in private channels to which the app has been added. - [groups:read](https://api.slack.com/scopes/groups:read)- View basic information about private channels to which the app has been added. - [im:history](https://api.slack.com/scopes/im:history)- View messages and other content in direct messages to which the app has been added. - [im:read](https://api.slack.com/scopes/im:read)- View basic information about direct messages that App has been added to. - [im:write](https://api.slack.com/scopes/im:write)- Start direct messages with people. - [incoming-webhook](https://api.slack.com/scopes/incoming-webhook)- Post messages to specific channels in Slack. - [mpim:history](https://api.slack.com/scopes/mpim:history)- View messages and other content in group direct messages that the app has been added to. - [mpim:read](https://api.slack.com/scopes/mpim:read)- View basic information about group direct messages that the app has been added to. - [team:read](https://api.slack.com/scopes/team:read)- View the name, email domain, and icon for workspaces the app is connected to. - [users:read](https://api.slack.com/scopes/users:read)- View people in a Slack workspace. - [links:write](https://api.slack.com/scopes/links:write)- Show previews of URLs in messages. - [channels:read](https://api.slack.com/scopes/channels:read)- View basic information about public channels in a workspace. - [chat:write.public](https://api.slack.com/scopes/chat:write.public)- Send messages to channels that the @Yellow test bot is not a member of. ![](https://i.imgur.com/zlmk4ai.png) ### Step 2: Subscribe to bot events After adding the redirect URL, you need to subscribe your app to bot events. Slack will notify your bot based on the user activity as per the specified URL. 1. Select **Event Subscriptions**. ![](https://i.imgur.com/yQJV2q9.png) 2. Toggle **Enable Events** and add the **Request URL** `https://cloud.yellow.ai/integrations/slack/receive/botID`. ![](https://i.imgur.com/VcYThF8.png) 3. In *Event subscription* section, expand **Subscribe to bot events** and click **Add Bot User Event** to add the scope according to your bot. For more details, click [common events](https://api.slack.com/events). ![](https://i.imgur.com/cQYL1pr.png) The following are required bot events: | Event Name | Description | -----------| -----------| | [app_home_opened](https://api.slack.com/events/app_home_opened) | The user clicked on the home tab of your tab. | | [app_mention](https://api.slack.com/events/app_mention) | Subscribe to only the message events that mention your app or bot. | | [message.channels ](https://api.slack.com/events/message.channels) | A message was posted to a channel. | | [message.groups](https://api.slack.com/events/message.groups) | A message was posted to a private channel. | | [message.im](https://api.slack.com/events/message.im) | A message was posted in a direct message channel. | | [message.mpim](https://api.slack.com/events/message.mpim)|A message was posted in a multiparty direct message channel. | 4. Click **Save changes.** ### Step 3: Add interactive messages To add interactive messages, follow these steps: 1. Select **Interactivity & Shortcuts**, enable the **Interactivity**, and add the request URL `https://cloud.yellow.ai/integrations/slack/receive/botID`. ![](https://i.imgur.com/BkNWWpN.png) ### Step 4: Enable permissions to interact with your bot You need to select your preferred permissions for your users to interact with the bot in the workplace. 1. Select **App Home** and enable the following permissions: * **Always show my bot as online** * **Show tabs** * **Messages tab** ![](https://i.imgur.com/MZ1JzkN.png) ### Step 5: Slash Commands **Slash Commands** allows users to invoke the app by typing a string into the message composer box. Slash commands are not sent as a message but as a command to the bot. Example: `/channel invite @bob to #tech Reference: https://api.slack.com/interactivity/slash-commands` Follow the below steps to add the slash command: 1. Go to `https://api.slack.com/apps/` > **Select your App** > select the **Slash Commands** in the left panel > **Create New Command**. ![](https://i.imgur.com/2ekQevv.png) 2. Enter the **Command**, **Short description**, and **Request URL** (`https://cloud.yellow.ai/integrations/slack/shortcuts/botID`) > click **Save**. ![](https://i.imgur.com/uQPsWzQ.png) 3. Enable `slack-shortcuts` event in the [Event Hub](https://docs.yellow.ai/docs/platform_concepts/studio/events/event-hub). If a flow is triggered using this event, you can access the event payload in builder using `{{data.event.[]}}`. The following is the schema for this event: ``` { "event": { "code": "slack-shortcuts", "data": { "command": "/raiseticket", "text": "pc is not working", "message": "pc is not working", "userId": "U01BXXX9A7" } } } ``` ### Step 6: Shortcuts You can use shortcuts to send commands to the bot. Shortcuts can be initiated from the **shortcuts** button in the message composer or from search. For more details, click [Shortcuts](https://api.slack.com/interactivity/shortcuts/using). ![](https://i.imgur.com/2qIzPz0.png) To add shortcuts, follow these steps: 1. Open api.slack.com **> Interactivity & Shortcuts > Create new Shortcut**. ![](https://i.imgur.com/CzzQbJu.png) ## Configure Single/Multi-workspace Slack apps can be built for both **single** workspace use cases (for example, apps for a particular organisation) and **multi-tenant** workspaces (example, apps for marketplaces). ### Single Workspace The Slack app uses a *`bot access token (xoxb)`* to communicate with workspace users. A Bot access token is obtained when the Slack workspace admin adds the app to their workspace. To configure a single workspace, follow these steps : 1. Select **OAuth & Permissions**, then click **Request to Install** to add the app to the Workspace. ![](https://i.imgur.com/c0q0Cfp.png) 2. Select a channel if you have enabled external incoming [webhooks](https://api.slack.com/messaging/webhooks). ![](https://i.imgur.com/DKInjMd.png) 3. After installing the app in workspace, go back to **OAuth & Permission**. Copy the Bot *`Access token (xoxb- )`*. ![](https://i.imgur.com/zssPPbX.png) 4. Log in to https://cloud.yellow.ai and navigate to **Overview** > **Channels** > **Messaging** > **Slack** > **Select token type** > **Slack tokens** > **Add the Slack access token** > **Save**. ![](https://i.imgur.com/vTd1WQT.png) 5. Navigate to the **Overview** page, under the **Active channels** section, you can see that the Slack channel is successfully connected to your bot. ![](https://i.imgur.com/NJbAFeO.png) ### Configure multiple workspaces Slack multi-workspace can be handled using the `OAuth token`, and the Yellow bot will map the `accessToken` to the requesting workspace's `teamId`. To configure multi-workspaces, follow the steps : 1. Go to `https://api.slack.com/apps/` 2. Select Basic Information and copy the **Client ID** & **Client Secret** <img src="https://i.imgur.com/IPcSv6T.png)" alt="drawing" width="70%"/> 2. Log in to https://cloud.yellow.ai and navigate to **Overview** > **Channels** > **Messaging** > **Slack** > **Select token** type > **OAuth tokens** > Add the **Client ID**, **Client Secret**, **Scope**, **User Scope** > **Save**. ![](https://i.imgur.com/9Mswcpr.png) 3. To use Slack APIs, you need to store the accessToken for each workspace by mapping accessToken with [APIs](#5). Set up a flow to capture your **`accessToken <> teamId`** mapping in the [Bot Table](https://docs.yellow.ai/docs/platform_concepts/studio/database#1-create-table): - Add a custom event `slack-oauth-access-token` in [Event Hub](https://docs.yellow.ai/docs/platform_concepts/studio/events/event-hub). You will receive this event each time your app is added to a workspace and will have the following schema: ``` { "event": { "code": "slack-oauth-access-token", "data": { "appId": "A03********", "teamId": "T03********", "teamName": "Slack Bot Testing", "accessToken": "xoxb-*************-***********-****************" } } } ``` - Using the above event, you can trigger a [flow](https://docs.yellow.ai/docs/platform_concepts/studio/build/Flows/configureflow). - In the triggered flow, you can access the accessToken with `{{data.event.data.accessToken}}` and teamId with `{{data.event.data.teamId}}`. - Store the above 2 mappings in the [Bot Table](https://docs.yellow.ai/docs/platform_concepts/studio/database#1-create-table) using the [Database Node](https://docs.yellow.ai/docs/platform_concepts/studio/build/nodes/action-nodes#database). 4. You can install a multi-workspace app through the OAuth flow by using the following link: `https://app.yellow.ai/integrations/slack/install/ botId` ## Add app to Slack workspace After adding the Slack app to the workspace, you can add the app to a channel for testing or interacting with the bot. To add the app to Slack workspace, follow these steps: 1. Under **Apps**, click **Add Apps**. <img src="https://i.imgur.com/yDZtZVj.png)" alt="drawing" width="40%"/> 2. In the **Search** bar, search for the app that you have created on the Slack website using the top workspace search or select the app. ![](https://i.imgur.com/gyzBJXj.png) * With this, your app will be added to the Slack workspace under the **Apps** section. <img src="https://i.imgur.com/ypcDOa0.png)" alt="drawing" width="40%"/> ### Add app to Channel To an Add app to the Channel, follow these steps: 1. Select **Channel** > click **channel drop-down** > **Integrations** > **Add an app**. You can add or remove the app from the channel. <img src="https://i.imgur.com/OUkXsAG.png)" alt="drawing" width="50%"/> 2. In the **Search** bar, You can search for the app or click **Add** to add your app. ![](https://i.imgur.com/AzvWZ39.png) * The app will be successfully added to the selected channel. > **Group or Channel**: The bot will reply in the threads, and context will be mentioned within the respective threads. ## Test your bot on Slack After connecting your bot to your Slack channel, you can test your bot. #### Prerequisite * You need to create the respective intents and configure bot flows with the same intent. For more information, click [here](https://docs.yellow.ai/docs/platform_concepts/Getting%20Started/create-a-bot). To test your bot on Slack, follow these steps: 1. Open your Slack app, under *Apps* select the app that you have created. ![](https://i.imgur.com/0KLB8LL.png) 2. Start the conversation to test your app. ![](https://i.imgur.com/PWPEvq6.png) ### API The [Slack Web API](https://api.slack.com/methods) serves as a means to retrieve data from and make modifications within a Slack workspace. #### Bot access token * **For single workspace configuration**, you would already have the accessToken. * **For multi-workspace configuration**, you should complete Step 3 mentioned in the Multi-Workspace Configuration guide. * To obtain the teamId for each user interacting with the bot, retrieve it from the [sender](https://docs.yellow.ai/docs/platform_concepts/studio/build/bot-variables#22-system-variables). The sender will be in the format `[teamId]_[userId]`. * Using the `teamId`, fetch the corresponding `accessToken` from the Bot Table.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully