

(You can still get the legacy version, see this answer)Īnother approach is to always use the token from the respective user for sending the message. This also works for the legacy version of Incoming Webhooks, not with the current version of incoming webhooks though. See here for more details on how it works. If you want to use it make sure to also set the as_user property to false (yes, really) and it will not work with a bot token, only with a user token.

Here is an example how it looks like (from a gamer Slack about flying and killing space ships):īut depending on what your requirements are that might work for you. However, this is not meant to impersonate real users, so even if you use the same username and icon as the real user the message will have the app tag, so that they can be distinguished from a real user. The message will then appear as being send by that user (same for icon with icon_url). error: " + messageResponse.errorĬonsole.When you send a message with chat.postMessage it is possible to set a user name with the property username. JsonConvert.DeserializeObject(responseJson) Var response = await client.PostAsync("", httpContent) Var content = JsonConvert.SerializeObject(msg) Ĭ = new AuthenticationHeaderValue("Bearer", token) Public static async Task SendMessageAsync(string token, SlackMessage msg) throws exception if message can not be sent Var isValid = response.IsSuccessStatusCode ? "valid" : "invalid" Ĭonsole.WriteLine($"Received Var response = await slackClient.SendMessageAsync(testMessage) Payload testMessage = new Payload(message) Var slackClient = new SlackClient(webhookUrl) Private static async Task IntegrateWithSlackAsync() This is from someone who posted this online! But I changed and added a few things: public static void Main(string args) Okay, enough whining! I'll show you now what I got so far. if I try to put them in the Payload they are just ignored, it seems. Also I do not understand how to use arguments like a token, specific userId, a specific channel. I also do not understand how to use the url-methods like " " - where do they go? As you might see in my code I only have the webhookurl, and if I don't use that one I can not post to anything. I just do not understand what the "payload" for JSON has to look like (actually I'm doing it exactly like it says on Slack's Website, but it doesn't work at all - it always ignores things like "token", "user", "channel" etc.). Problem is I have to do this for my company, so we can integrate slack to our own Software.

And I can not do it as myself(under my slackID), just as the App. I can not for the life of me post a message to another channel than the one I webhooked.
