-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using interactive-messages within lambda #896
Comments
Unfortunately, there is no documentation for the use case at the moment. If your Lambda functions directly use the Considering the circumstances, creating an Express instance and converting it to a Lambda handler (we can use this npm modle by AWS or other options) may be simpler. Also, it makes testing the function on a local machine pretty easy. |
The You simply called the I believe that for most serverless environments, you can implement the function the environment expects by calling the function you get from the method. This is essentially how the popular |
Thanks all, I managed to get around limitations using the Here's the mock adaptor, I just instantiate it with the callback i'd like called when // emulate a stripped down http response adapter for slack
class ResponseAdapter {
constructor(callback) {
this.callback = callback;
this.headers = {};
this._statusCode = 200;
}
set statusCode(val) {
this._statusCode = val;
}
setHeader(key, val) {
this.headers[key] = val;
}
end(content) {
const data = {
status: this._statusCode,
json: content,
headers: this.headers,
};
this.callback(data);
}
} and used something like this: const handler = (req) {
const interactions = createMessageAdapter(process.env.SIGNING_SECRET);
const listen = interactions.requestListener();
// setup handlers
interactions.action(
/*...*/
);
const customResponseCreator = (status, json, headers) => {
// create and process the response I actually need to send
};
const res = new ResponseAdapter(customResponseCreator);
listen(req, res); |
Whoa, that’s pretty neat. Thanks for sharing! |
For others searching, you can directly use https://github.com/vendia/serverless-express if you include a middleware to populate const app = express();
app.use((req, res, next) => {
// serverless-express populates `req.body` which makes interactive-messages error out unless
// `req.rawBody` is populated.
// As long as API Gateway is configured as a simple proxy to Lambda, the rawBody will be untouched
// and interactive-messages will successfully verify signatures.
if (req.body) {
req.rawBody = req.body;
}
next();
});
app.use(createMessageAdapter(slackSigningSecret).requestListener());
// this app can now be used with serverless-express
export { app }; |
Not sure if people are still having this issue but we had it with Azure functions. Turns out we needed to pass the content-type as |
Description
I'm writing a serverless slack application and have been looking at using interactive-messages.
It seems quite tightly coupled with running a server.
dispatch()
is marked as an internal method, however it seems like there should be a way for a serverless setup to manually pass a payload to the dispatcher.Is this use case documented anywhere?
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Packages:
Select all that apply:
@slack/web-api
@slack/events-api
@slack/interactive-messages
@slack/rtm-api
@slack/webhooks
The text was updated successfully, but these errors were encountered: