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 data) for a variety of response methods through the message adapter.

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 branchId

branchId: undefined | string

id

id: string = bot.random()

Optional message

message: bot.Message

method

method: string = "send"

Optional payload

payload: any

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

Methods

attach

  • attach(payload: any): this
  • Add multi-media attachments to a message, could be buttons or files etc

    Parameters

    • payload: any

    Returns this

compose

  • compose(...content: any[]): this
  • Helper for attaching or writing depending on a dynamic array of items

    Parameters

    • Rest ...content: any[]

    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