Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Slack API documentation for FAKE 5 #1706

Merged
merged 3 commits into from
Oct 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FAKE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "markdown", "markdown", "{B9222464-CAAC-4E5F-81A0-408C7BEFDBF3}"
ProjectSection(SolutionItems) = preProject
help\markdown\404.md = help\markdown\404.md
help\markdown\api-slack.md = help\markdown\api-slack.md
help\markdown\contributing.md = help\markdown\contributing.md
help\markdown\core-targets.md = help\markdown\core-targets.md
help\markdown\dotnet-assemblyinfo.md = help\markdown\dotnet-assemblyinfo.md
Expand Down Expand Up @@ -97,7 +98,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "markdown", "markdown", "{B9
help\markdown\todo-iis.md = help\markdown\todo-iis.md
help\markdown\todo-msteamsnotification.md = help\markdown\todo-msteamsnotification.md
help\markdown\todo-octopusdeploy.md = help\markdown\todo-octopusdeploy.md
help\markdown\todo-slacknotification.md = help\markdown\todo-slacknotification.md
help\markdown\legacy-slacknotification.md = help\markdown\legacy-slacknotification.md
help\markdown\todo-stylecop.md = help\markdown\todo-stylecop.md
help\markdown\todo-teamcity.md = help\markdown\todo-teamcity.md
help\markdown\todo-teamcityadvanced.md = help\markdown\todo-teamcityadvanced.md
Expand Down
52 changes: 52 additions & 0 deletions help/markdown/api-slack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Sending Notifications to a Slack Webhook

In this article you will learn how to create a [Slack](https://slack.com) webhook integration and send a notification to it. This article assumes that you already have a Slack team setup.

**Note: This documentation is for FAKE 5. The old documentation can be found [here](legacy-slacknotification.html)! **

[API-Reference](apidocs/fake-api-slack.html)

## Adding a Webhook Integration to a Channel

Follow the [instructions](https://my.slack.com/services/new/incoming-webhook/) for setting up an incoming webhook integration. When finished, you should have a Webhook URL that looks like "https://hooks.slack.com/services/some/random/text".

## Sending a Notification to the Webhook

open Fake.Api

// The webhook URL from the integration you set up
let webhookUrl = "https://hooks.slack.com/services/some/random/text"

Slack.SendNotification webhookUrl (fun p ->
{p with
Text = "My Slack Notification!\n<https://google.com|Click Here>!"
Channel = "@SomeoneImportant"
IconEmoji = ":ghost:"
Attachments = [|
{Slack.NotificationAttachmentDefaults with
Fallback = "Attachment Plain"
Text = "Attachment Rich"
Pretext = "Attachment Pretext"
Color = "danger"
Fields = [|
{Slack.NotificationAttachmentFieldDefaults with
Title = "Field Title 1"
Value = "Field Value 2"}
{Slack.NotificationAttachmentFieldDefaults with
Title = "Field Title 1"
Value = "Field Value 2"}|]
}
{Slack.NotificationAttachmentDefaults with
Fallback = "Attachment 2 Plain"
Text = "Attachment 2 Rich"
Pretext = "Attachment 2 Pretext"
Color = "#FFCCDD"
}|]
})
|> printfn "Result: %s"

The result should look something like this:

![alt text](pics/slacknotification/slacknotification.png "Slack Notification Result")

For additional information on the parameters, check out Slack's [Webhook Documentation](https://api.slack.com/incoming-webhooks)
4 changes: 2 additions & 2 deletions help/redirects/slacknotification.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This page moved to:

- Not jet migrated to FAKE 5
- [here for FAKE 4](todo-slacknotification.html) (Final location not decided jet)
- [here for FAKE 5](api-slack.html)
- [here for FAKE 4](legacy-slacknotification.html) (Final location not decided yet)

7 changes: 6 additions & 1 deletion help/templates/template.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
<li @Raw(Properties["CurrentPage"] == "Modules" ? "class=\"current_page_item\"" : "")>
<a href="@(prefix)fake-fake5-modules.html">Modules</a>
<ul>
<li>
<a href="@(prefix)apidocs/index.html#Fake.Api">API</a>
<ul>
<li><a href="@(prefix)api-slack.html">Slack</a></li>
</ul>
</li>
<li>
<a href="@(prefix)core.html">Core</a>
<ul>
Expand Down Expand Up @@ -131,7 +137,6 @@
<li><a href="@(prefix)todo-androidpublisher.html">?.?.AndroidPublisher</a></li>
<li><a href="@(prefix)todo-watch.html">IO.FileWatcher</a></li>
<li><a href="@(prefix)todo-wix.html">Windows.WiX</a></li>
<li><a href="@(prefix)todo-slacknotification.html">API.Slack</a></li>
<li><a href="@(prefix)todo-msteamsnotification.html">API.MsTeams</a></li>
<li><a href="@(prefix)todo-stylecop.html">DotNet.StyleCop</a></li>
<li><a href="@(prefix)todo-deploy.html">Fake.Deploy</a></li>
Expand Down