Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Slackit API Reference

OrgaChem edited this page · 4 revisions
Clone this wiki locally

Slackit provide 3 bot templates:

Interfaces

BotLike

new BotLike(Object: options): BotLike

An interface for bots. This interface requires to implement 2 methods (#start and #stop).

Instance methods

BotLike#start

BotLike#start()

Start the bot.

BotLike#stop

BotLike#stop()

Stop the bot.

ReceivableBot

new ReceivableBot(Object: options): ReceivableBot

An interface for receivable bot extends BotLike. This interface requires to implement 2 methods (#listen and #close).

Instance methods

ReceivableBot#listen

ReceivableBot#listen([function: opt_callback])

Listens outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot start listening.

ReceivableBot#close

ReceivableBot#close([function: opt_callback])

Stops listening outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot stop listening.

SendableBot

new SendableBot(Object: options): SendableBot

An interface for sendable bot extends BotLike. This interface requires to implement 1 methods (#say).

Instance methods

SendableBot#say

SendableBot#say(Object|string: message)

Says the given message by using official incoming WebHooks. Send the message to #general if the channel property is omitted.

  • string: message

    Message text or object that should have a message as a text property. You can specify a channel as a channel property, a botname as a botname and an user icon as a icon_emoji. See https://{your team name}.slack.com/services/new/incoming-webhook.

Classes

BasicBot

new BasicBot(Object: options): BotLike

A class for BasicBots implements ReceivableBot and SendableBot. The options should have 4 properties and optional 3 properties are available.

  • string: options.teamname

    Name of the your team (equals the sub domain of your slack page)

  • string: options.botname

    Name of the bot.

  • number: options.port

    Port to listen outgoing WebHooks.

  • string: options.incomingHookToken

    Token for incoming WebHooks.

  • string: options.outgoingHookToken

    Token for outgoing WebHooks.

  • string: options.channel (default: #general)

    Default channel to send a message by the bot.

  • string: options.outgoingHookURI (default: /outgoing-hook)

    Default path to receive new messages from the Slack server.

  • boolean: options.http (default: false)

    Use HTTP if true (not recommended).

This class works by delegating to receivingMechanism as ReceivableBot and sendingMechanism as SendableBot.

Instance methods

BasicBot#say

BasicBot#say(Object|string: message)

Says the given message by using official incoming WebHooks. Send the message to #general if the channel property is omitted.

  • Object|string: message

    Message text or object that should have a message as a text property. You can specify a channel as a channel property, a botname as a botname and an user icon as a icon_emoji. See https://{your team name}.slack.com/services/new/incoming-webhook.

BasicBot#listen

BasicBot#listen([function: opt_callback])

Listens outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot start listening.

BasicBot#close

(protected) BasicBot#close([function: opt_callback])

Stops listening outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot stop listening.

BasicBot#createReceivingMechanism

(protected) BasicBot#createReceivingMechanism(Object: options): ReceivableBot

Creates a receiving mechanism. The options should have a property and optional 2 properties are available.

  • number: options.port

    Port to listen outgoing WebHooks.

  • string: options.outgoingHookToken

    Token for outgoing WebHooks.

  • string: options.outgoingHookURI (default: /outgoing-hook)

    Default path to receive new messages from the Slack server.

  • boolean: options.http (default: false)

    Use HTTP if true (not recommended).

BasicBot#createSendingMechanism

BasicBot#createSendingMechanism(Object: options): SendableBot

Creates a sending mechanism. The options should have 3 properties and an optional propertiy are available.

  • string: options.teamname

    Name of the your team (equals the sub domain of your slack page)

  • string: options.botname

    Name of the bot.

  • string: options.incomingHookToken

    Token for incoming WebHooks.

  • string: options.channel (default #general)

    Default channel to send a message by the bot.

ReceptBot

new ReceptBot(Object: options): ReceptBot

A class for ReceptBots. The options should have a property and optional 2 properties are available.

  • string: options.outgoingHookToken

    Token for outgoing WebHooks.

  • string: options.outgoingHookURI (default /outgoing-hook)

    Default path to receive new messages from the Slack server.

  • boolean: options.http (default false)

    Use HTTP if true (not recommended).

Instance methods

ReceptBot#listen

ReceptBot#listen([function: opt_callback])

Listens outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot start listening.

ReceptBot#close

(protected) ReceptBot#close([function: opt_callback])

Stops listening outgoing WebHooks.

  • function: opt_callback (optional)

    Callback wil be invoked when the bot stop listening.

SendBot

new SendBot(Object: options): BotLike

A class for SendBots implements SendableBot. The options should have 4 properties and optional 3 properties are available.

  • string: options.teamname

    Name of the your team (equals the sub domain of your slack page)

  • string: options.botname

    Name of the bot.

  • number: options.port

    Port to listen outgoing WebHooks.

  • string: options.incomingHookToken

    Token for incoming WebHooks.

  • string: options.outgoingHookToken

    Token for outgoing WebHooks.

  • string: options.channel (default: #general)

    Default channel to send a message by the bot.

  • string: options.outgoingHookURI (default: /outgoing-hook)

    Default path to receive new messages from the Slack server.

  • boolean: options.http (default: false)

    Use HTTP if true (not recommended).

This class works by delegating to receivingMechanism as ReceivableBot and sendingMechanism as SendableBot.

Instance methods

SendBot#say

SendBot#say(Object|string: message)

Says the given message by using official incoming WebHooks. Send the message to #general if the channel property is omitted.

  • Object|string: message

    Message text or object that should have a message as a text property. You can specify a channel as a channel property, a botname as a botname and an user icon as a icon_emoji. See https://{your team name}.slack.com/services/new/incoming-webhook.

Something went wrong with that request. Please try again.