Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

This repository was created in the aim of demonstrating the possibilities of proper FaaS (AWS Lambda, Google Cloud Functions etc) environment support by Bolt.

Notifications You must be signed in to change notification settings

seratch/bolt-aws-lambda-proof-of-concept

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@slack/bolt-aws-lambda prototype

This repository was created in the aim of demonstrating the possibilities of proper FaaS (AWS Lambda, Google Cloud Functions etc) environment support by Bolt. As of December 2019, there is no plan to merge this implementation into Bolt framework.

How it works

import { AwsLambdaReceiver } from './src/added/AwsLambdaReceiver';
import { TwoPhaseApp } from './src/added/TwoPhaseApp';
import { sleep } from './src/added/helpers';

const app = new TwoPhaseApp({
  token: process.env.SLACK_BOT_TOKEN,
  receiver: new AwsLambdaReceiver({
    signingSecret: process.env.SLACK_SIGNING_SECRET
  })
});

app.command('/lambda')
  .ack(({ ack }) => {
    ack('ack response');
  })
  .then(async ({ body, say }) => {
    app.logger.info("You are here after the acknowledgement...");
    let totalMillis = 0;
    while (totalMillis < 5000) { // sleep for 5 seconds
      totalMillis += 1000;
      await sleep(1000);
      app.logger.info('Sleeping...');
    }
    app.logger.info("Let's go!");
    return say('How are you?').then(() => say("I'm good!"));
  });

export const main = app.receiver().toHandler();

demo

Run the app on your local machine

cp _env .env
# edit .env
npm i
npm i serverless -g
sls offline --printOutput

Deploy the app onto AWS

export SLACK_BOT_TOKEN=xoxb-xxxxxxxxx
export SLACK_SIGNING_SECRET=xxxxxxxxx
export SERVERLESS_STAGE=dev
sls deploy --stage ${SERVERLESS_STAGE} -v

About

This repository was created in the aim of demonstrating the possibilities of proper FaaS (AWS Lambda, Google Cloud Functions etc) environment support by Bolt.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published