Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Envelope

Envelopes are the outgoing equivalent of a message. They can be created to respond to a received message, or initialised to send unprompted by input. The envelope contains address details and the content (strings or payload) for a variety of response methods through the message adapter. Helpers provide simple interface for adding strings and attachments, but the payload property can be used to access additional helpers for rich content.

Hierarchy

  • Envelope

Implements

Index

Constructors

constructor

  • Create an envelope to dispatch unprompted or from a branch callback.

    • Addresses to a message's origin from a processed state if given
    • Provide address and content as options (overriding those in state)
    • Address to user's room if user given. If room given, will override user

    Parameters

    • Optional options: IEnvelope
    • Optional b: bot.State

    Returns Envelope

Properties

Optional _payload

_payload: bot.Payload

Optional branchId

branchId: undefined | string

id

id: string = bot.random()

Optional message

message: bot.Message

method

method: string = "send"

Optional responded

responded: undefined | number

room

room: object

Type declaration

  • Optional id?: undefined | string
  • Optional name?: undefined | string
  • Optional type?: undefined | string

Optional strings

strings: string[]

Optional user

user: bot.User

Accessors

payload

Methods

attach

compose

  • compose(...content: Array<string | IAttachment>): this
  • Helper for attaching or writing depending on a dynamic array of items

    Parameters

    Returns this

toRoomId

  • toRoomId(id: string): this
  • Set room ID attribute, clear room name so adapter will use ID

    Parameters

    • id: string

    Returns this

toRoomName

  • toRoomName(name: string): this
  • Set room name attribute, clear room ID so adapter will use name

    Parameters

    • name: string

    Returns this

toUser

  • toUser(user: User): this
  • Set user attribute, overwrites room if user has room attribute

    Parameters

    Returns this

via

  • via(method: string): this
  • Helper to set the method to be used by message adapter to respond/send

    Parameters

    • method: string

    Returns this

write

  • write(...strings: string[]): this
  • Add string content to an envelope, could be message text or reaction

    Parameters

    • Rest ...strings: string[]

    Returns this

Generated using TypeDoc