user3636388
user3636388

Reputation: 237

SlackBot: Dialog is not invoked from App home

Error invoking a dialog from Slack new app home using a button. Using AWS lambda and NodeJS. Link followed: https://api.slack.com/tutorials/app-home-with-modal

Sample API call:

POST https://slack.com/api/views.open

Body:

{"view": "{'type':'modal','title':{'type':'plain_text','text':'Request leave','emoji':true},'submit':{'type':'plain_text','text':'Submit','emoji':true},'close':{'type':'plain_text','text':'Cancel','emoji':true},'blocks':[{'type':'divider'},{'type':'input','element':{'type':'datepicker','placeholder':{'type':'plain_text','text':'Select a date','emoji':true}},'label':{'type':'plain_text','text':'Start date','emoji':true}},{'type':'input','optional':true,'element':{'type':'datepicker','placeholder':{'type':'plain_text','text':'Select a date','emoji':true}},'label':{'type':'plain_text','text':'End date','emoji':true}},{'type':'input','label':{'type':'plain_text','text':'Reason','emoji':true},'element':{'type':'plain_text_input','multiline':true},'optional':true}]}",
  "trigger_id": "9%%%%00d5bb3e5"
}

Headers:

Content-Type => application/json; charset=iso-8859-1
Authorization => Bearer  xoxb-94*******

Error:

{"ok":false,"error":"dispatch_failed"} in the browser network tab

Update: http_service_error when I use slash command with dialog.open / views.open

Upvotes: 1

Views: 1949

Answers (1)

user3636388
user3636388

Reputation: 237

const web = new WebClient(process.env.BOT_TOKEN);
(async () => {
    await web.views.open({
        trigger_id: body.trigger_id,
        view: {<my block>},
    });
})();

This worked!

Upvotes: 1

Related Questions