Skip to content

Commit

Permalink
Slack Integration (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin authored Sep 20, 2021
1 parent a34e611 commit ee192ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Alpha Build'

on:
push:
branches: [v470/prev-sessions-view]
branches: [v470/slack]

jobs:
build:
Expand Down
10 changes: 10 additions & 0 deletions backend/src/slack/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Testing Slack

https://slack.dev/node-slack-sdk/tutorials/local-development

## Using ngrok

- Install ngrok: `brew install ngrok`
- Setup token: login to https://dashboard.ngrok.com/get-started/setup and run the `ngrok authtoken XXX` command
- Run ngrok and proxy to the locally running backend: `ngrok http 8081`
- On slack, update the URL: https://api.slack.com/apps/A01G1U9DP17/interactive-messages?
24 changes: 1 addition & 23 deletions backend/src/slack/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function slackRouter(): Router {

router.post('/create', async (req, res) => {
const msg: SlackSlashCommand = req.body;
console.log('Request: ', msg);
const session = await createSessionFromSlack(msg.user_id, msg.text);
try {
if (session) {
Expand All @@ -35,7 +34,7 @@ export default function slackRouter(): Router {
} else {
await sendToSlack(
msg.response_url,
`Unfortunately, we could not identify you on Retrospected. Try logging in with your Slack account at least once on Retrospected.`
`Unfortunately, we could not identify you on Retrospected. Try logging in with your Slack account at least once on Retrospected, so we can link your Retrospected account with your Slack account.`
);
}
} catch (err) {
Expand All @@ -58,26 +57,5 @@ export default function slackRouter(): Router {
console.log('response: ', result);
}

router.post('/shortcut', async (req, res) => {
const msg: SlackSlashCommand = req.body;
console.log('Request: ', msg);
// try {
// const response = await fetch(msg.response_url, {
// method: 'POST',
// body: JSON.stringify({
// response_type: 'in_channel',
// text: `Hey great! let's create a new retrospective: https://localhost:3000/game/${shortid()}`,
// }),
// headers: { 'Content-Type': 'application/json' },
// });
// const result = await response.text();
// console.log('response: ', result);
// } catch (err) {
// console.error(err);
// }

return res.status(200).send();
});

return router;
}

0 comments on commit ee192ea

Please sign in to comment.