Slack Node SDK code is failing to execute
Description
Hi Team,
I am building an APP using Node Slack SDK. I am able to authenticate the user by using auth.test URL and also able to post start up message using im.open or chat.postMessage in the slack.
I am able to authenticate the user in both scenarios ( with proxy as well as without proxy )
While in Proxy environment, I am getting error as Error: Slack request signing verification failed. After posting the message ( line # 25 ), i am getting error
It will be helpful if you can help me in debugging the issue. How can i put a tracer to find the exact issue in the below code.
const slackEventsApi = require('@slack/events-api'); const {createMessageAdapter} = require('@slack/interactive-messages'); const { WebClient } = require('@slack/client'); const HttpsProxyAgent = require('https-proxy-agent');
const proxyUrl = ${process.env.proxyUrl}:${process.env.proxyPort}; web: new WebClient(process.env.SLACK_BOT_TOKEN, { agent: new HttpsProxyAgent(proxyUrl) }),
userDetails() {
console.log("\n this.web.im.open :: ", this.web.im.open);
console.log("\n this.user :: ", this.user);
var text = Welcome to user! I'm here to help your;
this.web.im.open({user:this.this.user})
.then((res) => {
console.log("inside the slack open method :: ", res);
this.web.chat.postMessage({channel:res.channel.id, text, as_user: true, parse: 'full'})
})
.catch((err) => {
console.log("error code ::: ", err);
});
console.log("\n method bypassed :: "); },
Slack package details :
"@slack/client": "^4.8.0", "@slack/events-api": "^2.1.1", "@slack/interactive-messages": "^1.0.2",
From Console Log:
inside the slack open method :: { ok: true,
no_op: true,
already_open: true,
channel: { id: 'xxxxx' },
scopes: [ 'identify', 'bot:basic' ],
acceptedScopes: [ 'im:write', 'post' ] }
/opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:168
throw userError;
^
Error: Slack request signing verification failed
at verifyRequestSignature (/opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:84:18)
at /opt/app-root/src/node_modules/@slack/events-api/dist/http-handler.js:189:11
at
What type of issue is this? (place an x in one of the [ ])
- [ ] bug
- [ ] enhancement (feature request)
- [ x ] question
- [ x ] documentation related
- [ ] testing related
- [ x ] discussion
Requirements (place an x in each of the [ ])
- [x ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [ x] I've read and agree to the Code of Conduct.
- [x ] I've searched for any related issues and avoided creating a duplicate issue.
Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
@slack/client version: 4.8.0
node version:8.9.4 OS version(s): Windows 10
Steps to reproduce:
1. 2. 3.
Expected result:
What you expected to happen
Actual result:
What actually happened
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
Hi @JanmejayPattanaik 👋,
This error is related to request signing. That means it doesn't have anything to do with the WebClient calls you are making (with or without a proxy). Instead, its related to the @slack/events-api (or possibly the `@slack/interactive-messages) package. This repo isn't the right place for those issues. Don't worry, I'll still help you here.
Did you use the request signing secret when initializing the event adapter in your code? Please see the example to understand how this is done.
PS. Please use code fences (```) around the code you put in any issues. Reading code the way you've posted is really difficult, especially with indentation and callbacks. This made it take more time to understand what you're doing.
Hi Ankur,
Thank you for your guidance. I am able to resolve the signing issue.
Post signing, I need to open the dialog. It was working fine for the earlier version of Slack Node SDK but after upgrading the Slack Node SDK version, the same is not working.
Please help me in resolving the same. The below code supposed to open a Slack dialog. I am unable to see any error in the console while executing the code
Sample Code:
`const { WebClient } = require('@slack/client');
web: new WebClient(process.env.SLACK_BOT_TOKEN);
const dialogForm = this.getDialog();
openDialog(triggerId, dialogForm) { console.log('openDialog::', triggerId); const dialog = JSON.stringify(dialogForm); this.web.dialog.open(dialog, triggerId).then((res) => { if (res.status === 200 && res.data.ok) { return Promise.resolve('Successfully posted the dialog'); } return Promise.resolve('Dialog could not be opened'); }).catch("222 :: ", console.error); },`
` getDialog(callbackId, title = '', details = '', priority) {
return {
title: 'Header',
callback_id: callbackId,
submit_label: 'Request',
elements: [
{
label: 'Title',
type: 'text',
name: 'title',
value: title,
placeholder: 'Summary of the request'
},
{
label: dvPriority,
type: 'select',
name: 'priority',
value: priority,
options: [
{ label: 'Low', value: 'Low' },
{ label: 'Medium', value: 'Medium' },
{ label: 'High', value: 'High' },
],
},
{
label: 'Description',
type: 'textarea',
name: 'details',
value: details,
optional: true,
},
],
};
} `
-
Please open a new issue when you have unrelated problems. In this case, again it would be an issue in the
@slack/interactive-messagesproject. -
Looks like you've tried to use the markdown code fences, but might need a little more help. Check out this guide. Also the "Preview" tab in the editing area is useful to check if it looks right 😄
It would be helpful to everyone in the community if you closed an issue when you've resolved it, and let people know what solution worked. In this case, I'm going to close the issue because the original question is solved, but please do reach out in the other project!