dkfann-dd-test / slackapps-repository

https://lab.github.com/bitprj/creating-slack-apps-with-bolt-framework-nodejs-and-apis
0 stars 0 forks source link

Week 2 #8

Closed github-learning-lab[bot] closed 2 years ago

github-learning-lab[bot] commented 2 years ago

Block Kits and Actions

Introduction to BlockKits and Actions in the Slack API.

If you missed the livestream or are unable to view the recording, here is a link to a written copy: https://github.com/bitprj/BitCamp/blob/master/Slack-Apps/week2/blog.md

Block Kits are a more advanced way of sending messages through an app. In this issue, you will build an app that uses block kits. to interact with users.

Reading up

You will need to do some research on block kits in order to understand how they work. Read the following documentation for more guidance:

  1. Making a stack of blocks: https://api.slack.com/block-kit/building
  2. Interactivity in blocks: https://api.slack.com/block-kit/interactivity
  3. Block types: https://api.slack.com/reference/block-kit/blocks

Actions

An action is a way to listen to events in Slack. Instead of listening for something that generally happens, you can listen for something that a user does in the workspace. Below is a basic example of an action:

app.action('<event_id>', async ({ body, ack, <any other functions>}) => {
  // Acknowledge the action
  await ack();
});

One thing you always have to do in an action is aknowledge that the event occurred. Afterwards, you can use the payload from the action for your own purposes.

Building Your App

Now it's time to make a block kit yourself! Your goal will be to write an app that will listen for the word 'hello' in a workspace's channels, then respond in the same channel announcing that who person said hello. The message should include a block kit with a button saying 'click me'. If someone clicks the button, then the app announces that a person clicked the button in a regular message.

Refer to the links above and this example of a block kit in a function call:

await say({
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "plain_text",
                "text": "This is a plain text section block.",
                "emoji": true
            }
        }
    ]
});

Hint: Note in the template that a block can have an event id. This means that you can listen for events within the block (i.e. a button being clicked)

After you have finished, make sure to commit any file changes you made. To do this, please create a branch off of the master called week(x) with x being the # of the week you are on. For that week you will need to create a PR for every Learning Lab step to review and make sure your work is correct. For example: After finishing step 1.2, make a new branch off of week(x) and call it week(x)-1.2 (with 1.2 being the step you're on). Then create a Pull Request between week(x) and week(x)-1.2. After reviewing you're PR or having another user review it, merge you're work and continue.

REMINDER: If you are part of the MENTORED group, after you complete all steps within a certain week and followed the instructions above, create a Pull Request with your work from week(x) to master and assign your mentor as a reviewer. If you are an open-source user, do the same but self-review your PR to continue to the next week.

dkfann-dd-test commented 2 years ago

.