node-slack-interactive-messages icon indicating copy to clipboard operation
node-slack-interactive-messages copied to clipboard

Unable to open the Slack dialog

Open JanmejayPattanaik opened this issue 7 years ago • 2 comments

Description

Hi Ankur,

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.

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

Slack package details : ( Recently upgraded @slack/client 4.8.0 from 3.9.0 and the similar up-gradation for other packages as well )

"@slack/client": "^4.8.0", "@slack/events-api": "^2.1.1", "@slack/interactive-messages": "^1.0.2",

Sample Code:


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((error) => console.log("Error :: ", 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,
			},
		],
	};
}

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [x ] question
  • [ ] documentation related
  • [ ] testing related
  • [x ] discussion

Requirements

  • [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.

JanmejayPattanaik avatar Jan 10 '19 15:01 JanmejayPattanaik

@JanmejayPattanaik i think the problem is here: this.web.dialog.open(dialog, triggerId). in the @slack/client v4.x, for all Web API methods, the arguments are passed in a single object, with the individual arguments as properties of the object. in this one case, you should fix this by changing it to this.web.dialog.open({ dialog, trigger_id: triggerId}).

this information is also available in the migration guide. i suggest you read that guide carefully. then find all the web API methods you use to make this change to the arguments.

aoberoi avatar Jan 10 '19 21:01 aoberoi

Thank you for your inputs @aoberoi . This definitely helped me in resolving the issue.

JanmejayPattanaik avatar Jan 14 '19 15:01 JanmejayPattanaik