I'm trying to build a slack app that will enable publishing channel messages after filling in a form. To do so, I created a slash-command that invoke a modal. Now I have a problem how to access this input data and use it to compose a message that will be send to chosen channel.
app.command('/spotkanie', async ({ ack, body, context }) => {
// Acknowledge the command request
await ack();
try {
const result = await app.client.views.open({
token: context.botToken,
// Pass a valid trigger_id within 3 seconds of receiving it
trigger_id: body.trigger_id,
// View payload
view_id: "view_spotkanie",
user_id: "user",
view: {
"type": "modal",
"callback_id": "zaplanuj-spotkanie",
"title": {
"type": "plain_text",
"text": "Zaplanuj spotkanie",
"emoji": true
},
"submit": {
"type": "plain_text",
"text": "Wyślij",
"emoji": true
},
"close": {
"type": "plain_text",
"text": "Anuluj",
"emoji": true
},
"blocks": [
{
"type": "input",
"element": {
"type": "datepicker",
"action_id": "data",
"placeholder": {
"type": "plain_text",
"text": "To wspaniały dzień na spotkanie!",
"emoji": true
}
},
"label": {
"type": "plain_text",
"text": "Data",
"emoji": true
}
},
{
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "godzina",
"placeholder": {
"type": "plain_text",
"text": "O której godzinie będzie spotkanie?",
"emoji": true
}
},
"label": {
"type": "plain_text",
"text": "Godzina",
"emoji": true
}
},
{
"type": "input",
"element": {
"type": "static_select",
"action_id": "rodzaj",
"placeholder": {
"type": "plain_text",
"text": "Jaki jest rodziaj spotkania?",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "spotkanie ogólne",
"emoji": true
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "spotkanie projektowe",
"emoji": true
},
"value": "value-1"
},
{
"text": {
"type": "plain_text",
"text": "spotkanie integracyjne",
"emoji": true
},
"value": "value-2"
}
]
},
"label": {
"type": "plain_text",
"text": "Rodzaj spotkania",
"emoji": true
}
},
{
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "miejsce",
"placeholder": {
"type": "plain_text",
"text": "Gdzie odbędzie się spotkanie?",
"emoji": true
}
},
"label": {
"type": "plain_text",
"text": "Miejsce",
"emoji": true
}
},
{
"type": "input",
"optional": true,
"element": {
"type": "plain_text_input",
"action_id": "dodatkowe info",
"placeholder": {
"type": "plain_text",
"text": "Wpisz dodatkowe informacje, takie jak agenda, link do spotkania itp",
"emoji": true
},
"multiline": true
},
"label": {
"type": "plain_text",
"text": "Więcej informacji",
"emoji": true
}
},
{
"block_id": "my_block_id",
"type": "input",
"label": {
"type": "plain_text",
"text": "Wyślij do",
},
"element": {
"action_id": "channel_id",
"type": "channels_select",
"response_url_enabled": true,
"placeholder": {
"type": "plain_text",
"text": "Gdzie wysłać powiadomienie o spotkaniu?",
"emoji": true
}
}
}
]
}
});
console.log(result);
}
catch (error) {
console.error(error);
}
});
app.view('zaplanuj-spotkanie', async ({ ack, body, view, context, say }) => {
Now this app.view should give me the access to the input data, according to Slack instructions but I still have no idea how to use it.