Skip to content

Commit

Permalink
Adds HelpRequest Handler (#10)
Browse files Browse the repository at this point in the history
* Adds basic handler for presenting slack user with dialog to request help for a service

* Swap out old example handler for help handler

This commit removes the DialogTest handler that was used for testing.
main.go now uses the HelpRequest handler when '/slack/command/help' is
hit.
  • Loading branch information
iwishiwerearobot authored and adampointer committed Jul 18, 2018
1 parent 942fb0c commit ccb8ba3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ import (
"github.com/skybet/go-helpdesk/wrapper"
)

// DialogTest is a simple test handler to create a dialog in Slack
func DialogTest(w http.ResponseWriter, r *http.Request) error {
//get_the_formatted_request and from it get the trigger id
// HelpRequest is a handler that creates a dialog in Slack to capture a
// customers help request
func HelpRequest(w http.ResponseWriter, r *http.Request) error {
sc, err := slack.SlashCommandParse(r)
if err != nil {
return fmt.Errorf("Failed to parse slack slash command: %s", err)
}

descElement := slack.DialogTextElement{
descriptionElement := slack.DialogTextElement{
Type: "text",
Label: "Description",
Placeholder: "Description...",
Name: "FOO",
Label: "Help Request Description",
Placeholder: "Describe what you would like help with ...",
Name: "HelpRequestDescription",
}

elements := []slack.DialogElement{
descElement,
descriptionElement,
}

dialog := slack.Dialog{
CallbackId: "PETETEST",
Title: "Create an Incident",
CallbackId: "HelpRequest",
Title: "Request Help",
SubmitLabel: "Create",
NotifyOnCancel: true,
Elements: elements,
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
s := server.NewSlackReceiver()
r := &server.Route{
Path: "/slack/command/help",
Handler: handlers.DialogTest,
Handler: handlers.HelpRequest,
}

if err := s.AddRoute(r); err != nil {
Expand Down

0 comments on commit ccb8ba3

Please sign in to comment.