Sending command via Slack API

对着背影说爱祢 提交于 2021-01-27 22:15:43

问题


Is there a way to programmatically send a command to Slack via the API? I'm successfully posting a message using

var postingResponse = client.UploadValues("https://slack.com/api/chat.postMessage", 
                      "POST", new NameValueCollection() {
                            {"token","<token>"},
                            {"channel","<ID>"}, 
                            {"text", "/mycommand hello" },
                            {"username","<username>" },
                            {"link_names", "true" },
                            {"parse", "full" }
                       });

This works well but the /mycommand hello is just printed as text instead of executing as a command. I tried adding a pair {"command", "/mycommand hello" } but nothing happened either.

Thanks


回答1:


I did not try it out by myself, but according to this answer there is the undocumented API method chat.command for executing commands in public channels. There is also a Python program for sending commands to slack.



来源:https://stackoverflow.com/questions/45350521/sending-command-via-slack-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!