Reputation: 237
I'm trying to open a slack modal. The following is my JSON. The value is not passed when the field is put under accessory. I'm getting an error next to the field. Am I doing anything wrong? The same thing works when I put it inside input type blocks. Below is JSON code I built using Slack Block Kit Builder. I have added action_id also
{
"type": "modal",
"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": "section",
"text": {
"type": "mrkdwn",
"text": "To"
},
"accessory": {
"type": "static_select",
"action_id": "to_time",
"placeholder": {
"type": "plain_text",
"text": "Select an item",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "8 AM",
"emoji": true
},
"value": "8"
},
{
"text": {
"type": "plain_text",
"text": "9 AM",
"emoji": true
},
"value": "9"
},
{
"text": {
"type": "plain_text",
"text": "10 AM",
"emoji": true
},
"value": "10"
},
{
"text": {
"type": "plain_text",
"text": "11 AM",
"emoji": true
},
"value": "11"
},
{
"text": {
"type": "plain_text",
"text": "12 PM",
"emoji": true
},
"value": "12"
},
{
"text": {
"type": "plain_text",
"text": "1 PM",
"emoji": true
},
"value": "1"
},
{
"text": {
"type": "plain_text",
"text": "2 PM",
"emoji": true
},
"value": "2"
},
{
"text": {
"type": "plain_text",
"text": "3 PM",
"emoji": true
},
"value": "3"
},
{
"text": {
"type": "plain_text",
"text": "4 PM",
"emoji": true
},
"value": "4"
},
{
"text": {
"type": "plain_text",
"text": "5 PM",
"emoji": true
},
"value": "5"
}
]
}
}
]
}
The value is not passed
Upvotes: 0
Views: 1320
Reputation: 399
You need to use views.open
instead of dialog.open
. Since you are using block elements inside modal and hence it's suggested to use view.open
I hope this works for you.
Then check whether you have added a webhook for the interactive component.
Look's like the issue with your webhook URL can you please check once again? I tried with your JSON and it work's like a charm!
Code:
const data = {
token: authToken,
trigger_id: trigger_id,
view: {
// Json goes here
}
};
const headers = {
Authorization: `Bearer ${authToken}`
}
const response = await axios.post(`${apiUrl}/views.open`, data, { headers });
console.log(response.data);
return response;
Dialog:
Success Response:
Upvotes: 1