ConsoleConnector class

Connects a UniversalBot to the command line via a console window.

Methods

listen()

Starts the connector listening to stdIn.

onEvent((events: IEvent[], callback?: (err: Error) => void) => void)

Called by the UniversalBot at registration time to register a handler for receiving incoming events from a channel.

onInvoke((event: IEvent, cb?: (err: Error, body: any, status?: number) => void) => void)

Used to register a handler for receiving incoming invoke events.

processEvent(IEvent)

Sends a event through the connector.

processMessage(string)

Sends a message through the connector.

send(IMessage[], (err: Error, addresses?: IAddress[]) => void)

Called by the UniversalBot to deliver outgoing messages to a user.

startConversation(IAddress, (err: Error, address?: IAddress) => void)

Called when a UniversalBot wants to start a new proactive conversation with a user. The connector should return a properly formated address object with a populated conversation field.

Method Details

listen()

Starts the connector listening to stdIn.

function listen()

Returns

onEvent((events: IEvent[], callback?: (err: Error) => void) => void)

Called by the UniversalBot at registration time to register a handler for receiving incoming events from a channel.

function onEvent(handler: (events: IEvent[], callback?: (err: Error) => void) => void)

Parameters

handler

(events: IEvent[], callback?: (err: Error) => void) => void

onInvoke((event: IEvent, cb?: (err: Error, body: any, status?: number) => void) => void)

Used to register a handler for receiving incoming invoke events.

function onInvoke(handler: (event: IEvent, cb?: (err: Error, body: any, status?: number) => void) => void)

Parameters

handler

(event: IEvent, cb?: (err: Error, body: any, status?: number) => void) => void

processEvent(IEvent)

Sends a event through the connector.

function processEvent(event: IEvent)

Parameters

event
IEvent

Returns

processMessage(string)

Sends a message through the connector.

function processMessage(line: string)

Parameters

line

string

Returns

send(IMessage[], (err: Error, addresses?: IAddress[]) => void)

Called by the UniversalBot to deliver outgoing messages to a user.

function send(messages: IMessage[], callback: (err: Error, addresses?: IAddress[]) => void)

Parameters

messages

IMessage[]

callback

(err: Error, addresses?: IAddress[]) => void

startConversation(IAddress, (err: Error, address?: IAddress) => void)

Called when a UniversalBot wants to start a new proactive conversation with a user. The connector should return a properly formated address object with a populated conversation field.

function startConversation(address: IAddress, callback: (err: Error, address?: IAddress) => void)

Parameters

address
IAddress
callback

(err: Error, address?: IAddress) => void