namespace System
namespace System.IO
namespace System.Net
namespace SlackProvider
type TSlack = SlackTypeProvider<...>

Full name: Index.TSlack
Multiple items
namespace SlackTypeProvider

--------------------
type SlackTypeProvider

Full name: SlackProvider.SlackTypeProvider


Get your token at url: https://api.slack.com/tokens
val slack : SlackTypeProvider<...>

Full name: Index.slack
property SlackTypeProvider<...>.Channels: SlackTypeProvider<...>.ChannelsType
property SlackTypeProvider<...>.ChannelsType.xamarininsights: SlackTypeProvider<...>.ChannelType


Get channel with id C04085Z39
SlackTypeProvider<...>.ChannelType.Send(message: string, ?botname: string, ?asuser: bool, ?iconUrl: string) : bool


Send a message to a channel
property SlackTypeProvider<...>.Users: SlackTypeProvider<...>.UsersType
property SlackTypeProvider<...>.UsersType.romain_flechner: SlackTypeProvider<...>.UserType


Get user with id U040ADW4W
SlackTypeProvider<...>.UserType.Send(message: string, ?botname: string, ?asuser: bool, ?iconUrl: string) : bool


Send a message to a channel

Slack TypeProvider

Image of LoveFsharp Image of SlackLogo

by @rflechner

What is Slack TypeProvider?

  • A small F# library providing properties and methods generated form Slack API
  • An experimental use of F# Type Providers

What is the use?

  • Write a little bot sending messages on Slack with an autocomplete on user or channel list.

Getting started

Get an API token

Method1: Using your account

Get your token at url: https://api.slack.com/tokens

Method2: Create a bot account

Go to https://{your_company}.slack.com/apps/manage

Then click on "Custom Integrations" and "Bots"

NuGet

Get the NuGet package

Is it easy to use ?

See example below

Image of example1

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
open SlackProvider

//You can provide a file path or an URL or a raw token
type TSlack = SlackTypeProvider<token="C:/keys/slack_token.txt">
let slack = TSlack()

slack.Channels.xamarininsights.Send("test")
slack.Users.romain_flechner.Send("Hi !")

// Or with custom image and/or name
slack.Users.romain_flechner
    .Send("I am a bot",
        botname="robot 4", 
        iconUrl="http://statics.romcyber.com/icones/robot1_48x48.jpg")

For FAKE users

See FAKE website.

Modify your build.cmd or build.bat

In a project using NuGet, you can have something like:

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
@echo off
cls
".nuget\NuGet.exe" "Install" "FAKE" 
    "-OutputDirectory" "packages" "-ExcludeVersion"
".nuget\NuGet.exe" "Install" "SlackTypeProvider" 
    "-OutputDirectory" "packages" "-ExcludeVersion"
".nuget\NuGet.exe" "Install" "Newtonsoft.Json" 
    "-OutputDirectory" "packages" "-Version" "8.0.2"
"packages\FAKE\tools\Fake.exe" build.fsx %2

If you are using Paket, simply append next lines in your paket.dependencies:

1: 
2: 
3: 
4: 
group Build
    source https://nuget.org/api/v2
    nuget Newtonsoft.Json
    nuget SlackTypeProvider

Modify your build.fsx

Load assemblies

With NuGet

1: 
2: 
#r "packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll"
#r "packages/SlackTypeProvider/lib/net40/SlackTypeProvider.dll"

With the Paket example

1: 
2: 
#r "packages/build/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll"
#r "packages/build/SlackTypeProvider/lib/net40/SlackTypeProvider.dll"

Then you will be able to add slack notifications in your targets

1: 
2: 
3: 
4: 
5: 
Target "NotifyAppReleased" (fun _ ->
    slack.Channels.general.Send "Hi !"
    slack.Channels.general.
        Send "A new Android version of MyApp is on HockeyApp."
)