-
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
Getting Empty State at viewSubmission #935
Comments
A known common pitfall is that you need to use input blocks to have them as part of See also: slackapi/bolt-js#305 (comment) If your modal has some input blocks and they're not sent as you expect, could you share more details like your application code, Slack app settings, and so on? I'm happy to help you out. For your reference, here is a tiny code snippet that surely works. package.json{
"name": "slack-inter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"events": "node_modules/.bin/nodemon events.js",
"interactive": "node_modules/.bin/nodemon interactive.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@slack/events-api": "^2.3.0",
"@slack/interactive-messages": "^1.4.0",
"@slack/web-api": "^5.6.0",
"dotenv": "^8.2.0"
},
"devDependencies": {
"nodemon": "^2.0.2"
}
} .env
events.jsHow to run: const config = require("dotenv").config().parsed;
for (const k in config) {
process.env[k] = config[k];
}
const { createEventAdapter } = require('@slack/events-api');
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;
const slackEvents = createEventAdapter(slackSigningSecret, {
waitForResponse: true,
});
const { WebClient } = require('@slack/web-api');
const token = process.env.SLACK_BOT_TOKEN;
const web = new WebClient(token);
slackEvents.on('app_home_opened', (event) => {
web.views.publish({
token: token,
user_id: event.user,
view: {
"type": "home",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "You can add a button alongside text in your message. "
},
"accessory": {
"type": "button",
"action_id": "open-view",
"text": {
"type": "plain_text",
"text": "Button",
"emoji": true
},
"value": "click_me_123"
}
}
]
}
});
});
(async () => {
const server = await slackEvents.start(3001);
console.log(`Listening for events on ${server.address().port}`);
})(); interactive.jsHow to run: const config = require("dotenv").config().parsed;
for (const k in config) {
process.env[k] = config[k];
}
const { createMessageAdapter } = require('@slack/interactive-messages');
const slackSigningSecret = process.env.SLACK_SIGNING_SECRET;
const slackInteractions = createMessageAdapter(slackSigningSecret);
const token = process.env.SLACK_BOT_TOKEN;
const { WebClient } = require('@slack/web-api');
const web = new WebClient(token);
slackInteractions.action({ type: 'button' }, (payload) => {
web.views.open({
token: token,
trigger_id: payload.trigger_id,
view: {
"type": "modal",
"callback_id": "view-callback-id",
"title": {
"type": "plain_text",
"text": "My App",
"emoji": true
},
"submit": {
"type": "plain_text",
"text": "Submit",
"emoji": true
},
"close": {
"type": "plain_text",
"text": "Cancel",
"emoji": true
},
"blocks": [
{
"type": "input",
"element": {
"type": "users_select",
"placeholder": {
"type": "plain_text",
"text": "Select a user",
"emoji": true
}
},
"label": {
"type": "plain_text",
"text": "Label",
"emoji": true
}
}
]
}
})
});
slackInteractions.viewSubmission('view-callback-id', (payload) => {
console.log(payload.view.state);
return null;
});
(async () => {
const server = await slackInteractions.start(3002);
console.log(`Listening for events on ${server.address().port}`);
})(); |
Thank you :) I solved it ! |
Description
Describe your issue here.
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
Reproducible in:
package version:
node version: 10.16.3
OS version(s): macOS 10.15 Catalina
Steps to reproduce:
Expected result:
Getting state values at submission of dialog.
Actual result:
Getting empty state
The text was updated successfully, but these errors were encountered: