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 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

    Returns Envelope

Properties

Optional _payload

_payload: Payload

Optional branchId

branchId: undefined | string

id

id: string = random()

Optional message

message: Message

method

method: string = "send"

payload

  • get payload(): Payload

Optional responded

responded: undefined | number

room

room: Room

Optional strings

strings: string[]

user

user: User

Methods

attach

  • Add multi-media attachments to a message via payload handlers.

    Parameters

    Returns this

compose

  • compose(...content: Array<string | IAttachment>): this
  • Helper to attach or write depending on type of content.

    Parameters

    Returns this

createPayload

  • Assign payload attributes as new payload instance.

    Parameters

    Returns void

toRoomId

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

    Parameters

    • id: string

    Returns this

toUser

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

    Parameters

    Returns this

via

  • via(method: string): this
  • Set the method to be used by message adapter to respond.

    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