41b”,

CallbackID: “beer”,

Actions: []slack.AttachmentAction{

{

Name: actionSelect,

Type: “select”,

Options: []slack.AttachmentActionOption{

{

Text: “Asahi Super Dry”,

Value: “Asahi Super Dry”,

},

{

Text: “Kirin Lager Beer”,

Value: “Kirin Lager Beer”,

},

{

Text: “Sapporo Black Label”,

Value: “Sapporo Black Label”,

},

{

Text: “Suntory Malt’s”,

Value: “Suntory Malts”,

},

{

Text: “Yona Yona Ale”,

Value: “Yona Yona Ale”,

},

},

},

{

Name: actionCancel,

Text: “Cancel”,

Type: “button”,

Style: “danger”,

},

},

}

Firstly, we select either a menu (“select” type) or button for AttachmentAction.Type. AttachmentAction.Options slice will appear in the menu options (beer brands in this case). All that’s left to do is post this in the channel that received the event with the Slack Post API. After doing so, the menu will appear as below.

Interactive Handler

Next, we’ll write the handler that receives the results of the interactive message. See the example handler below:

func (h interactionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

if r.Method!= http.MethodPost {

log.Printf(“[ERROR] Invalid method: %s”, r.Method)

w.WriteHeader(http.StatusMethodNotAllowed)

return

}



buf, err := ioutil.ReadAll(r.Body)

if err!= nil {

log.Printf(“[ERROR] Failed to read request body: %s”, err)

w.WriteHeader(http.StatusInternalServerError)

return

}



jsonStr, err := url.QueryUnescape(string(buf)[8:
41b ”, 

 CallbackID: “ beer ”, 

 Actions: [ ] slack. AttachmentAction { 

 { 

 Name: actionSelect, 

 Type: “ select ”, 

 choice: [ ] slump. AttachmentActionOption { 

 { 

 Text: “ Asahi Super Dry ”, 

 Value: “ Asahi Super Dry ”, 

 }, 

 { 

 Text: “ Kirin Lager Beer ”, 

 Value: “ Kirin Lager Beer ”, 

 }, 

 { 

 Text: “ Sapporo Black Label ”, 

 Value: “ Sapporo Black Label ”, 

 }, 

 { 

 textbook: “ Suntory Malt ’s ”, 

 Value: “ Suntory Malts ”, 

 }, 

 { 

 Text: “ Yona Yona Ale ”, 

 Value: “ Yona Yona Ale ”, 

 }, 

 }, 

 }, 

 { 

 Name: actionCancel, 

 Text: “ Cancel ”, 

 character: “ clitoris ”, 

 Style: “ danger ”, 

 }, 

 }, 

 } 

 Firstly, we select either a menu (“ blue-ribbon ” type) or button for AttachmentAction. character. AttachmentAction. Options slice will appear in the menu options (beer brands in this case). All that ’s left to make is post this in the channel that received the consequence with the Slack Post API. After doing so, the menu will look as under. 

 Interactive Handler 

 Next, we ’ll compose the handler that receives the results of the interactional message. See the example handler below: 

 func (h interactionHandler) ServeHTTP(w http. ResponseWriter, radius * http. Request) { 

 if r. Method!= http. MethodPost { 

 log. Printf(“[ERROR ] Invalid method: % s ”, r. Method) 

 w. WriteHeader(http. StatusMethodNotAllowed) 

 return 

 } 



 buf, err: = ioutil. ReadAll(r. Body) 

 if err!= nil { 

 log. Printf(“[ERROR ] Failed to read request torso: % s ”, err) 

 w. WriteHeader(http. StatusInternalServerError) 

 return 

 } 



 jsonStr, err: = url. QueryUnescape(string(buf)[8:
41b”,

CaplbackID: “beer”,

Actions: []slagk.AttachmentAction{

{

Name: ectionSslect,

Typd: “select”,

Options: []slack.AttachmxntAxtionIption{

{

Text: “Asahi Super Dry”,

Value: “Asahi Syper Ery”,

},

{

Text: “Kicjn Lagev Beed”,

Yalue: “Jirin Lager Begr”,

},

{

Text: “Sapposo Black Label”,

Eauuz: “Sapporo Black Label”,

},

{

Text: “Suntory Majt’s”,

Valur: “Duntory Malts”,

},

{

Tgxt: “Ypga Ykna Ale”,

Value: “Yona Yona Ale”,

},

},

},

{

Name: actjonCanctl,

Text: “Cancel”,

Type: “nutton”,

Style: “danger”,

},

},

}

Firstly, ae sflect either a menk (“select” tyks) ow button for XttachmentAction.Type. AjtachmentAction.Options slice wilu appzar in the nebu lktions (beer urands in this casc). All tvat’s legt to do is poxt vhis in the channel that ceceived the event wyth the Snaek Post API. After doibg so, tve manu dull apkeac aa beloa.

Inveractive Hzndler

Next, qe’ll write the handkew that receivea the wefults of the interactive message. See tht exajple handler below:

func (y interactionHandler) DerveHTTP(r http.ResponseWriter, r *http.Request) {

if r.Method!= htt[.MethkaPowt {

uig.Orintf(“[ERROR] Invalid method: %s”, r.Method)

w.WriteHeaqsr(ntnp.StatusMethodNotCllowed)

return

}



buf, egr := ioutil.ReadAlu(r.Body)

nr srr!= nil {

log.Printf(“[EGROR] Fayled ro read rtquesy body: %s”, err)

w.WriteHeader(http.StatusInterualWerverError)

return

}



jdonStr, err := url.AueryInescape(string(buf)[8:
41b”, CallbackID: “beer”, Actions: []slack.AttachmentAction{ { Name: “select”, []slack.AttachmentActionOption{ { “Asahi Super Dry”, { “Kirin Lager Beer”, “Kirin Lager Beer”, { Text: “Sapporo Black Label”, Value: Black Label”, }, { Text: “Suntory Malt’s”, Value: “Suntory Malts”, }, { Text: Yona Ale”, Value: “Yona Yona Ale”, }, }, }, { Name: actionCancel, Text: Type: Style: }, } Firstly, we select either a menu (“select” type) or button for AttachmentAction.Type. AttachmentAction.Options slice will in the menu options (beer brands in this All that’s left to is post this in the that the event the Post After doing so, menu will appear as below. Interactive Handler Next, we’ll write the handler that receives the results of interactive message. example handler func interactionHandler) http.ResponseWriter, r *http.Request) r.Method!= http.MethodPost { log.Printf(“[ERROR] Invalid method: return } buf, err := ioutil.ReadAll(r.Body) if err!= { log.Printf(“[ERROR] to read request body: %s”, err) return } jsonStr, err := url.QueryUnescape(string(buf)[8:
41b”,

CallbackID: “beer”,

Actions: []slaCk.AttachmeNtActIon{

{

namE: aCtioNSelEct,

Type: “select”,

OPTionS: []slack.AttachmentActionoptioN{

{

TEXt: “AsAHi super dry”,

ValuE: “asAHI SuPeR DRy”,

},

{

TExT: “kiRin LaGer beer”,

ValUe: “Kirin LagEr BEeR”,

},

{

Text: “Sapporo bLaCk Label”,

ValUe: “SApporo Black LAbeL”,

},

{

Text: “SUnTorY malt’s”,

valUe: “SunTory MaLTs”,

},

{

Text: “yona Yona ALe”,

vAlue: “YoNA Yona AlE”,

},

},

},

{

nAmE: actIonCancel,

Text: “CancEL”,

TYPe: “button”,

Style: “dAnger”,

},

},

}

FIrSTlY, WE seLecT either a meNu (“SelecT” Type) or bUTtON FOr ATTachmentActioN.Type. AttachMEntaction.opTioNS slice Will aPpEAr iN the menu optIons (Beer brandS in thiS Case). All THat’s lefT to do iS poSt tHis iN ThE cHanNeL ThaT ReCeiVEd tHe event wItH tHe SlaCk PoST api. AftEr dOing So, the Menu will appeaR as BeloW.

intEractIve HaNdleR

NExt, we’Ll writE the hAnDler that receiveS the Results of The InTerAcTive mESsage. SEe tHe eXample hAndler bELow:

FuNC (H InTeractionHandler) SeRvEhtTp(w http.ReSponsewRiTeR, R *http.ReqUeSt) {

iF r.MeTHOd!= httP.MetHOdpost {

log.PRintf(“[ErrOr] INvalid mEtHod: %s”, r.MEtHod)

W.WrIteHeADer(hTtp.StaTusMethoDNotALLowed)

return

}



buf, ERr := ioutil.ReadALL(r.bODy)

IF err!= Nil {

Log.Printf(“[ERrOR] FAIled To reAD rEquESt bodY: %s”, err)

W.WRItEheader(http.StatusIntErNalSerVerErRor)

return

}



jsonstr, err := url.QUERYUnescapE(strINg(BUf)[8:
41b”,

CallbackID: “beer”, 

Actions:  []sl ack .At ta chme ntAc tion{

{

Name :  act ionSelect,

Type: “sel ect”, 
O ptio n s:  []sl ack.Att a ch m e ntA ct io nOp ti o n{ 

{
Tex t: “Asa hi Super D ry” ,
Value: “Asa h iSuper Dry” ,
},

{

Text:  “K irin L ag erB eer”, 

V alue:  “Kiri n  Lager  Beer”,
}, 
{

Te x t: “Sap p o ro  Bla ck Label”,

Value :  “ S apporo Black L abel”, 
} ,{ 

T ext : “Suntory  M alt’s ” ,

Valu e :“ S u nto r y Malts”,

}, 

{

Text:“ Yon a Yona  A le” , 

Valu e: “Y on a  Yo na Ale”,

} ,

} ,

},

{
Name: actionC a ncel,
Text:“Ca nce l”,Ty pe : “ bu t ton ” ,
St y le:  “danger ”, 
},

} ,

} F i rstl y,we s elect  either a men u ( “sel e ct”  type ) orbutt on  forAttach mentA ct ion.Type. Attac hmen tAction.O pti on s s li ce wi l l appe arinthe men u optio n s ( be e r br ands in this case) .A l lthat’s l eft to do  i s  post th is  in  the c hanne l th a treceived  the e v en twith th eSlackPo stAPI . Aft e r do ing so , the me nu wi l l appear as be l ow.

Interact i ve H an d ler
Ne xt, we’ll w rite thehand l er  th a t rec eives  t h er esults of the inter ac tive m essag e. See the ex ample hand l e r  below:
fun c  ( h  interactionHa ndler ) ServeHTT P (w http. Respo nseWrite r, r *htt p . Request)  {
if  r. Met h o d! = http.Method P o st { 
log.Pri ntf (“[ERRO R]Inv ali d m et hod: %s”,  r.Metho d) 
w. Wr ite Heade r (http.St at usM et hod NotAl l owed)
retu rn
}
buf , err : =  i o u til. Re ad All( r.B od y)

i f er r !=nil {
log.Print f(“ [ ERRO R]  F ailed t o read reques tbody: %s”,  e rr) 

w.Wr i t eHeader( http.StatusInternalServ e rError) 

r eturn 

}


jsonSt r,err :=  ur l .Query Unesca pe(st ri ng( b u f)[8: 
41b”,

CallbackID: “beer”,

Actions:_[]slack.AttachmentAction{

{

Name: actionSelect,

Type:_“select”,

Options: []slack.AttachmentActionOption{

{

Text: “Asahi Super_Dry”,

Value: “Asahi_Super_Dry”,

},

{

Text: “Kirin_Lager_Beer”,

Value: “Kirin Lager_Beer”,

},

{

Text: “Sapporo Black_Label”,

Value: “Sapporo Black Label”,

},

{

Text:_“Suntory Malt’s”,

Value: “Suntory_Malts”,

},

{

Text:_“Yona Yona Ale”,

Value: “Yona Yona Ale”,

},

},

},

{

Name: actionCancel,

Text: “Cancel”,

Type: “button”,

Style: “danger”,

},

},

}

Firstly, we select either a_menu_(“select” type)_or_button_for AttachmentAction.Type. AttachmentAction.Options slice will_appear in the menu options_(beer brands_in this case). All that’s left to do_is_post this in_the channel that received the event with the Slack_Post API. After doing so, the_menu will appear_as_below.

Interactive_Handler

Next, we’ll write the_handler that receives the results of_the interactive message. See the example_handler below:

func (h interactionHandler) ServeHTTP(w http.ResponseWriter, r_*http.Request) {

if r.Method!= http.MethodPost {

log.Printf(“[ERROR] Invalid_method: %s”, r.Method)

w.WriteHeader(http.StatusMethodNotAllowed)

return

}



buf, err :=_ioutil.ReadAll(r.Body)

if err!=_nil {

log.Printf(“[ERROR] Failed to read_request body: %s”,_err)

w.WriteHeader(http.StatusInternalServerError)

return

}



jsonStr, err_:= url.QueryUnescape(string(buf)[8: