edit:
I modified id of the plugin in code on both function… by the plugin name. The button try to send the message to an url with an id, not the name of the plugin.
Hi,
I made a plugin, i would to add an interactive mode to simplify usage instead of using slash commands. I use a docker image.
I try to understand but it’s not easy with matterpoll source, i would to have more comment in code to understand, and i add it’s a big plugin. Not the simpliest.
If i well understand, i must post a form with buttons, in this button i will set an address… this address must be an endpoint ? right?
If i read documentation about v4 this endpoint must be set in a yaml, there is no other way ? I don’t use make at all but a custom bash to compile and package. It’s because i compile most of time for c# under visual studio, i’m not habit with linux compiling.
I tried to remove almost everything ot understand the role of each part
On activate part, i start a func with something like:
r := mux.NewRouter()
r.HandleFunc("/api/v4/posts/{plugin code}/actions/meuporg", p.MeuporgHandler)
return r
On my command i create a post with (i have a problem with the root.manifest) and in URL i tried two things, a local IP + a context (commented) and a path like in matterpoll:
unc (p *FlowWatcherPlugin) SendTest(channelID string)*model.AppError{
p.API.LogDebug("SendTest")
post := &model.Post{
UserId: p.botUserID,
ChannelId: channelID,
Message: "This is just a test.",
}
actions := []*model.PostAction{}
fooAction:=&model.PostAction{
Id: fmt.Sprintf("meuporg"),
Name: "answer",
Type: model.PostActionTypeButton,
Style: "default",
Integration: &model.PostActionIntegration{
URL: "/api/v4/posts/fio9dg5xsf83fb4xwz47xr75ch/actions/meuporg",
/*
URL: "http://127.0.0.1:{port}",
Context: map[string]any{
"action": "do_something_ephemeral",
}, */
},
}
actions = append(actions, fooAction )
slackAttach := []*model.SlackAttachment{{
//AuthorName: "authorName",
Title: "p.Question",
Text : "Actions realisables",
Actions: actions,
}}
model.ParseSlackAttachment(post, slackAttach)
if _, err := p.API.CreatePost(post); err != nil {
p.API.LogDebug(
"We could not create the form post",
"user_id", post.UserId,
"err", err.Error(),
)
}
return nil
}
In theory it’s just a message with one button, and only one action possible.
I got an error in logs:
..."msg":"Action integration error.","caller":"web/context.go:113","path":"/api/v4/posts/fio9dg5xsf83fb4xwz47xr75ch/actions/meuporg","request_id":"9nihrx7edf8p8mqternyf834be","ip_addr":"172.23.0.1","user_id":"ujtnkspj9i8bdqiwc9hwpufhfo","method":"POST","err_where":"DoActionRequest","http_code":400,"error":"DoActionRequest: Action integration error., status=405"}
I ask myself also by writing this, if plugin id doesn’t change each time i overwrite it by uploading with the IHM.
If there is a way to not using endpoint, i prefer.
Best regards.