Response

Response

Class representing a response to a Slack message.

Constructor

new Response(bot)

Create a bot response.
Source:
Parameters:
Name Type Description
bot Bot The bot to use when responding.
Examples

Respond to a Slack message

await Bot.Response.create(bot)
    .to(message)  // a Botkit message object
    .as(alias)    // an alias instance or the name of one
    .with('Hello World!');

Respond to a Slack message using a bot method

const bot = new Bot();
await bot.replyTo(message).with('Hello World!');

Methods

(static) create() → {Response}

Create a bot command (see Response for parameters).
Source:
Returns:
Type:
Response
The new command.

as(alias) → {Response}

Set an alias to respond with.
Source:
Parameters:
Name Type Description
alias String | Alias The alias to respond with. This must be either an Alias or the name of one registered the bot.
Throws:
Will throw if the alias is not known.
Type
TypeError
Returns:
Type:
Response
The calling response instance.

to(incomingMessage) → {Response}

Set the incoming message to respond to.
Source:
Parameters:
Name Type Description
incomingMessage Object The Slack message to respond to.
Throws:
Will throw if incoming message is not a Slack message.
Type
TypeError
Returns:
Type:
Response
The calling response instance.

with(outgoingMessage) → {Promise}

Set the outgoing message.
Source:
Parameters:
Name Type Description
outgoingMessage String | Object The message to respond with.
Throws:
Will throw if the outgoing message is invalid.
Type
TypeError
Returns:
Type:
Promise
A promise which resolves when the message is sent.