You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I was trying to build a slack app and deploy it to aws. I built the app and it works fine but when I try and create other js files to import them in my main, the aws post url doesn't work.
..... The others are node_modules, .serverless etc.
So basically, without the import of app_home.js, the code works when deployed to aws lambda. On the slack app, it sends a message back when you type in hello. But when I add an import, the whole thing, doesn't work.
This works:
"use strict";
const { App, AwsLambdaReceiver, WorkflowStep } = require('@slack/bolt');
// Initialize your custom receiver
const awsLambdaReceiver = new AwsLambdaReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET,
});
// Initializes your app with your bot token and the AWS Lambda ready receiver
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: awsLambdaReceiver,
// The `processBeforeResponse` option is required for all FaaS environments.
// It allows Bolt methods (e.g. `app.message`) to handle a Slack request
// before the Bolt framework responds to the request (e.g. `ack()`). This is
// important because FaaS immediately terminate handlers after the response.
processBeforeResponse: true
});
// Listens to incoming messages that contain "hello"
app.message('hello', async ({ message, say }) => {
// say() sends a message to the channel where the event was triggered
await say({
text: `Hey there <@${message.user}>! \n Have any questions or concerns, Please contact the IT team.`
});
});
// Handle the Lambda function event
module.exports.handler = async (event, context, callback) => {
const handler = await awsLambdaReceiver.start();
return handler(event, context, callback);
}
Where as, this doesn't work at all:
"use strict";
const { App, AwsLambdaReceiver, WorkflowStep } = require('@slack/bolt');
// THIS IS THE LINE THAT I CHANGED FROM THE PREVIOUS CODE
const app_home = require('./app_home')
// Initialize your custom receiver
const awsLambdaReceiver = new AwsLambdaReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET,
});
// Initializes your app with your bot token and the AWS Lambda ready receiver
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: awsLambdaReceiver,
// The `processBeforeResponse` option is required for all FaaS environments.
// It allows Bolt methods (e.g. `app.message`) to handle a Slack request
// before the Bolt framework responds to the request (e.g. `ack()`). This is
// important because FaaS immediately terminate handlers after the response.
processBeforeResponse: true
});
// Listens to incoming messages that contain "hello"
app.message('hello', async ({ message, say }) => {
// say() sends a message to the channel where the event was triggered
await say({
text: `Hey there <@${message.user}>! \n Have any questions or concerns, Please contact the IT team.`
});
});
// Handle the Lambda function event
module.exports.handler = async (event, context, callback) => {
const handler = await awsLambdaReceiver.start();
return handler(event, context, callback);
}
So, I was just working, if it is a deployment issue?
Hi,
So I was trying to build a slack app and deploy it to aws. I built the app and it works fine but when I try and create other js files to import them in my main, the aws post url doesn't work.
The structure of my project(app) is:
Slack-app:
-------------- app.js
-------------- app_home.js
-------------- package.json
-------------- package-lock.json
-------------- serverless.yml
..... The others are node_modules, .serverless etc.
So basically, without the import of app_home.js, the code works when deployed to aws lambda. On the slack app, it sends a message back when you type in hello. But when I add an import, the whole thing, doesn't work.
This works:
Where as, this doesn't work at all:
So, I was just working, if it is a deployment issue?
My code for serverless is:
package.json looks like this
The text was updated successfully, but these errors were encountered: