@@ -44,48 +44,100 @@ app.post('/command', (req, res) => {
4444 if ( signature . isVerified ( req ) ) {
4545 // create the dialog payload - includes the dialog structure, Slack API token,
4646 // and trigger ID
47- const dialog = {
47+ const view = {
4848 token : process . env . SLACK_ACCESS_TOKEN ,
4949 trigger_id,
50- dialog : JSON . stringify ( {
51- title : 'Submit a helpdesk ticket' ,
50+ view : JSON . stringify ( {
51+ type : 'modal' ,
52+ title : {
53+ type : 'plain_text' ,
54+ text : 'Submit a helpdesk ticket'
55+ } ,
5256 callback_id : 'submit-ticket' ,
53- submit_label : 'Submit' ,
54- elements : [
57+ submit : {
58+ type : 'plain_text' ,
59+ text : 'Submit'
60+ } ,
61+ blocks : [
5562 {
56- label : 'Title' ,
57- type : 'text' ,
58- name : 'title' ,
59- value : text ,
60- hint : '30 second summary of the problem' ,
63+ block_id : 'title_block' ,
64+ type : 'input' ,
65+ label : {
66+ type : 'plain_text' ,
67+ text : 'Title'
68+ } ,
69+ element : {
70+ action_id : 'title' ,
71+ type : 'plain_text_input'
72+ } ,
73+ hint : {
74+ type : 'plain_text' ,
75+ text : '30 second summary of the problem'
76+ }
6177 } ,
6278 {
63- label : 'Description' ,
64- type : 'textarea' ,
65- name : 'description' ,
66- optional : true ,
79+ block_id : 'description_block' ,
80+ type : 'input' ,
81+ label : {
82+ type : 'plain_text' ,
83+ text : 'Description'
84+ } ,
85+ element : {
86+ action_id : 'description' ,
87+ type : 'plain_text_input' ,
88+ multiline : true
89+ } ,
90+ optional : true
6791 } ,
6892 {
69- label : 'Urgency' ,
70- type : 'select' ,
71- name : 'urgency' ,
72- options : [
73- { label : 'Low' , value : 'Low' } ,
74- { label : 'Medium' , value : 'Medium' } ,
75- { label : 'High' , value : 'High' } ,
76- ] ,
77- } ,
78- ] ,
79- } ) ,
93+ block_id : 'urgency_block' ,
94+ type : 'input' ,
95+ label : {
96+ type : 'plain_text' ,
97+ text : 'Importance'
98+ } ,
99+ element : {
100+ action_id : 'urgency' ,
101+ type : 'static_select' ,
102+ options : [
103+ {
104+ text : {
105+ type : "plain_text" ,
106+ text : "High"
107+ } ,
108+ value : "high"
109+ } ,
110+ {
111+ text : {
112+ type : "plain_text" ,
113+ text : "Medium"
114+ } ,
115+ value : "medium"
116+ } ,
117+ {
118+ text : {
119+ type : "plain_text" ,
120+ text : "Low"
121+ } ,
122+ value : "low"
123+ }
124+ ]
125+ } ,
126+ optional : true
127+ }
128+ ]
129+ } )
80130 } ;
81131
132+ console . log ( 'open view' )
133+
82134 // open the dialog by calling dialogs.open method and sending the payload
83- axios . post ( `${ apiUrl } /dialog .open` , qs . stringify ( dialog ) )
135+ axios . post ( `${ apiUrl } /views .open` , qs . stringify ( view ) )
84136 . then ( ( result ) => {
85- debug ( 'dialog .open: %o' , result . data ) ;
137+ debug ( 'views .open: %o' , result . data ) ;
86138 res . send ( '' ) ;
87139 } ) . catch ( ( err ) => {
88- debug ( 'dialog .open call failed: %o' , err ) ;
140+ debug ( 'views .open call failed: %o' , err ) ;
89141 res . sendStatus ( 500 ) ;
90142 } ) ;
91143 } else {
@@ -103,14 +155,14 @@ app.post('/interactive', (req, res) => {
103155
104156 // check that the verification token matches expected value
105157 if ( signature . isVerified ( req ) ) {
106- debug ( `Form submission received: ${ body . submission . trigger_id } ` ) ;
158+ debug ( `Form submission received: ${ body . view } ` ) ;
107159
108160 // immediately respond with a empty 200 response to let
109161 // Slack know the command was received
110162 res . send ( '' ) ;
111163
112164 // create Helpdesk ticket
113- ticket . create ( body . user . id , body . submission ) ;
165+ ticket . create ( body . user . id , body . view ) ;
114166 } else {
115167 debug ( 'Token mismatch' ) ;
116168 res . sendStatus ( 404 ) ;
0 commit comments