public async Task <IActionResult> SendAsync([FromForm] SlackMsgRequest msgRequest) { await slackBotService.SendAsync(msgRequest); var response = new SlackBotResponses { text = msgRequest.text, channel = msgRequest.channel }; return(Ok(response)); }
public async Task <string> SendAsync(SlackMsgRequest msgRequest) { var data = new NameValueCollection(); data["token"] = token; data["channel"] = msgRequest.channel; data["as_user"] = msgRequest.as_user; if (data["as_user"] == "false") { data["token"] = "xoxb - 914359964370 - 920226424034 - 5eUglTta5udR23ci4r6KlkDV"; } // to send this message as the user who owns the token, false by default data["text"] = msgRequest.text; var response = webClient.UploadValues("https://slack.com/api/chat.postMessage", "POST", data); string responseInString = Encoding.UTF8.GetString(response); return(responseInString); }