Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds HelpRequest Handler #10

Merged
merged 3 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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