Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Sep 20, 2016 @ 16:59
    Alex Skrypnyk
    0

    Integration With Slack

    Hi Community,

    We are playing with Umbraco Forms, we want to integrate results of Umbraco Forms to Slack channel, is it possible?

    Can somebody share?

    Thanks,

    Alex

  • Sven Geusens 169 posts 881 karma points c-trib
    Sep 21, 2016 @ 09:30
    Sven Geusens
    1

    In forms workflow - add item there is a type called "Post form to Slack Chat"

    Another possible way might be to hook into the "RecordInserting" event from Umbraco.Forms.Data.Storage.RecordStorage and call the slack Api yourself (https://api.slack.com/methods/chat.postMessage)

    And if all else fails, use the Post form to url with the url being your own api in umbraco which then posts the data to the slap api.

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Sep 21, 2016 @ 10:51
    Alex Skrypnyk
    0

    Hi Sven,

    Thank you very much for your response.

    Do you have some example of code how to call slack API?

    Thanks

  • Sven Geusens 169 posts 881 karma points c-trib
    Sep 21, 2016 @ 11:53
    Sven Geusens
    100
    public void PostToSlack(string text, string username = null, string channel = null)
        {
            Payload payload = new Payload()
            {
                Channel = channel,
                Username = username,
                Text = text
            };
    
            string payloadJson = JsonConvert.SerializeObject(payload);
    
            using (WebClient client = new WebClient())
            {
                NameValueCollection data = new NameValueCollection();
                data["payload"] = payloadJson;
    
                var response = client.UploadValues("your slack webhook url here", "POST", data);
            }
        }
    
    public class Payload
    {
        [JsonProperty("channel")]
        public string Channel { get; set; }
    
        [JsonProperty("username")]
        public string Username { get; set; }
    
        [JsonProperty("text")]
        public string Text { get; set; }
    }
    

    And info on how to create the webhook url: http://www.programmableweb.com/news/how-to-integrate-webhooks-slack-api/how-to/2015/10/20

  • Biagio Paruolo 1621 posts 1914 karma points c-trib
    Sep 21, 2016 @ 12:45
    Biagio Paruolo
    1

    +1

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Sep 21, 2016 @ 12:26
    Alex Skrypnyk
    0

    Sven, thank you very much !!!

    Have a nice day!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies