Skip to content
This repository was archived by the owner on Oct 9, 2021. It is now read-only.

Commit 4a78042

Browse files
committed
updated slack lab steps with new images and steps
1 parent 80c9075 commit 4a78042

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

Images/Slack-Step17.png

193 KB
Loading

Images/Slack-Step22.png

-63.4 KB
Loading

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -297,46 +297,44 @@ In this section, you'll create a slack group and wire it up to the Chat Service.
297297

298298
1\. Go to [http://www.slack.com](http://www.slack.com) and create a username, as well as a team.
299299

300-
2\. Once logged into Slack, navigate to [https://slack.com/apps](https://slack.com/apps) and click **Configure** near the top of the page.
300+
2\. Once logged into Slack, navigate to [https://slack.com/apps](https://slack.com/apps) and click **Build your own** near the top of the page. Then on the next screen, select **Make a Custom Integration**.
301301

302-
3\. On the "Configure" page, select **Custom Integrations** and then **Slack Commands** to create a Slack Command. Slash commands allow you to define a command that will trigger commands to execute. In this case you'll configure your Slash Command to make a POST request to an external URL.
302+
3\. On the "Custom Integration" page, select **Slack Commands** to create a Slack Command. Slash commands allow you to define a command that will inform Slack to forward your message to an external source with a webhook. In this case you'll configure your Slash Command to make a POST request to an external URL (the URL for your API Gateway endpoint).
303303

304-
4\. On the Slash Commands page, define a command in the **Commands** text box. Insert **/survivors** as your Slack Command.
304+
4\. On the Slash Commands page, define a command in the **Commands** text box. Insert **/survivors** as your Slack Command. Then select "Add Slash Command Integration" to save it.
305305

306-
5\. Make sure the **Method** section has "POST" selected from the dropdown options. Then scroll to the **Token** section and copy the Token (or generate a new one) to a text file as you'll need it in the following steps.
306+
5\. On the Integration Settings page, make sure the **Method** section has "POST" selected from the dropdown options. Then scroll to the **Token** section and copy the Token (or generate a new one) to a text file as you'll need it in the following steps.
307307

308308
6\. Keep the Slack browser tab open and in another tab navigate to the Lambda service in the AWS Management Console.
309309

310310
7\. Click **Create a Lambda function**. You'll create a Lambda function to parse incoming Slack messages and send them to the Chat Service.
311311

312-
8\. We'll use a blueprint here - in the blueprint filter box, type in **slack** and click the Lambda function titled **slack-echo-command**, which should be a Node.js function.
312+
8\. Skip past the blueprints page as we will not be using one.
313313

314-
9\. Name the function **SlackService**. **Delete all of the code in the inline edit window.** For this workshop, we've modified the blueprint to do some additional parsing as well as make an HTTPS request to the Chat Service.
314+
9\. Name the function **SlackService**. Now navigate to the GitHub repo for this workshop, or the location where you downloaded the GitHub files to your local machine.
315315

316-
10\. Open the **SlackService.js** file from the GitHub repo. Copy the entire contents of this js file into the Lambda inline edit window.
316+
10\. Open the **SlackService.js** file from the GitHub repo, found in the slack folder. Copy the entire contents of this js file into the Lambda inline edit window.
317317

318-
11\. Input the Slack Token string that you copied earlier into function. You should copy the string in the "token" variable replacing the string **INSERT YOUR TOKEN FROM SLACK HERE** with your own token.
318+
11\. Input the Slack Token string that you copied earlier into the function. You should copy the Token string from Slack into the "token" variable in the Lambda function, replacing the string **INSERT YOUR TOKEN FROM SLACK HERE** with your own token.
319319

320-
12\. In the "post_options" host variable, you will insert the URL to your Chat Service (/message) API Gateway resource so that the HTTPS requests can be sent with the messages from Slack. It should show a value of "INSERT YOUR API GATEWAY URL HERE EXCLUDING THE HTTPS://" for the **host** variable. Please replace this string with the URL of your **/message POST method**. Please be sure to remove the "https://" portion of the URL and the end of the URL "/ZombieWorkshopStage/zombie/message". Your final URL inputted into the code should look something like "xxxxxxxx.execute-api.us-west-2.amazonaws.com". Your code is now configured to check if the token sent with the request matches the token for your Slack integration. If so, it parses the data and makes an HTTPS request to your **/message** endpoint with the message from Slack.
320+
12\. In the "post_options" host variable, you will insert the URL to your Chat Service (/zombie/message) API Gateway resource so that the HTTPS requests can be sent with the messages from Slack. It should show a value of "INSERT YOUR API GATEWAY URL HERE EXCLUDING THE HTTPS://" for the **host** variable. Replace this string with the URL of your **/message POST method**. Please be sure to remove the "https://" portion of the URL and the end of the URL "/ZombieWorkshopStage/zombie/message". Your final URL inputted into the code should look something like "xxxxxxxx.execute-api.us-west-2.amazonaws.com". Your code is now configured to check if the token sent with the request matches the token for your Slack integration. If so, it parses the data and makes an HTTPS request to your **/message** endpoint with the message from Slack.
321321

322322
13\. Scroll down to the Role dropdown and select **Basic execution role**. On the verification window that appears to confirm the role, click **Allow**. This Lambda function will not interact with any AWS services. It does emit event data to CloudWatch Logs but that permission is provided by default with the basic execution role.
323323

324-
14\. Click **Next**. Now since we are using a Lambda blueprint, the Lambda function creation process will take you through an abbreviated setup of the API Gateway resource that will be associated with this Slack Service function. You should be on a page named **Configure endpoints**.
324+
14\. Click **Next**.
325325

326-
15\. On the **Configure endpoints** page, change the API Gateway to **Zombie Workshop API Gateway**, the Resource name to **slack**, the Method to **POST**, and the Security to **Open**. The final configuration should match the configurations shown below:
327-
![Slack API Endpoint Configuration](/Images/Slack-Step15.png)
326+
15\. On the review page, make sure that everything looks correct.
328327

329-
**We're leaving our API Gateway endpoints open in this workshop. This is to allow survivors (or your teammates and other groups) to help you extend functionality freely. In production we recommend locking down the security of these resources**.
328+
16\. Click **Create function**. Your Lambda function will be created.
330329

331-
16\. Click **Next** and on the Review page, click **Create function**. Your Lambda function will be created as well as the Slack resource in API Gateway.
330+
17\. When the function is created, navigate to the API Gateway service in the AWS Management Console. Click into your "Zombie Workshop API Gateway" API. On the left Resources pane, click/highlight the "/zombie" resource so that it is selected and highlighted blue. Then select the "Create Resource" button. For Resource Name, insert **slack** and for Resource Path, insert **slack**. The final resource for your Slack API should be as shown below.
331+
![Create Slack API Resource](/Images/Slack-Step17.png)
332332

333-
17\. When the function is created, an API endpoint URL should be displayed for you in the "API Endpoints" tab on the Lambda page. Copy that endpoint to a text editor as you'll need it in the following steps.
333+
18\. Click "Create Resource" to create your slack API resource. For your newly created "/slack" resource, highlight it, then click **Create Method** and select POST from the dropdown. Click the checkmark to create the POST method. On the Setup page, choose an Integration Type of **Lambda Function**, select "us-west-2" for the region dropdown, and type "SlackService" for the name of the Lambda Function. It should autofill your function name. Click **Save**.
334334

335-
18\. Navigate to the API Gateway console and click the POST method for the newly created **/slack** resource.
335+
19\. Click **Integration Request** for the /slack POST method. We'll create a Mapping Template to convert the incoming query string parameters from Slack into JSON which is the format Lambda requires for parameters. This mapping template is required so that the incoming Slack message can be converted to the right format.
336336

337-
19\. Click **Integration Request** for the /slack POST method. We'll create a Mapping Template to convert the incoming query string parameters from Slack into JSON which is the format Lambda requires for parameters.
338-
339-
20\. Expand the Mapping Templates arrow and click **Add mapping template**. In the Content-Type box, enter **application/x-www-form-urlencoded** and click the little black checkmark to continue. As you did in the Twilio lab, we're going to copy VTL mapping logic to convert the request to JSON. A new section will appear on the right side of the screen called "Input passthrough". Click the pencil icon next to "Input passthrough". In the dropdown that appears, select the **Mapping template** option.
337+
20\. Expand the Mapping Templates arrow and click **Add mapping template**. In the Content-Type box, enter **application/x-www-form-urlencoded** and click the little checkmark to continue. As you did in the Twilio lab, we're going to copy VTL mapping logic to convert the request to JSON. A new section will appear on the right side of the screen called "Input passthrough". Click the pencil icon next to "Input passthrough". In the dropdown that appears, select the **Mapping template** option.
340338
In the text editor, copy the following into the editor:
341339

342340
```
@@ -348,7 +346,7 @@ Click the little checkmark icon to continue. The result should look like the scr
348346

349347
21\. Click the blue **Deploy API** button on the left side of the API Gateway console to deploy your API. In the Deploy API window, select **ZombieWorkshopStage** from the dropdown and click **Deploy**.
350348

351-
22\. On the left pane navigation tree, expand the ZombieWorkshopStage tree. Click the **POST** method for the /slack resource. You should see an Invoke URL appear for that resource as shown below.
349+
22\. On the left pane navigation tree, expand the ZombieWorkshopStage tree. Click the **POST** method for the **/zombie/slack** resource. You should see an Invoke URL appear for that resource as shown below.
352350
![Slack Resource Invoke URL](/Images/Slack-Step22.png)
353351

354352
23\. Copy the entire Invoke URL. Navigate back to the Slack Command setup page and insert your Slack API Gateway Invoke URL into the "URL" textbox. Make sure to copy the entire url including "HTTPS://". Scroll to the bottom of the Slack Command screen and click **Save Integration**.

0 commit comments

Comments
 (0)