• Public
  • Public/Protected
  • All

Module events

Events is the base communication channel of the bot. Messages and payloads are a part of it, and it is the only way to receive or send information. Each event goes through the whole middleware chain (incoming or outgoing) before being received by either the bot or the user.




  • When Event Storage is enabled, you can use this API to query data about stored events. You can use multiple fields for your query, but at least one is required.


    • fields: Partial<StoredEvent>

      One or multiple fields to add to the search query

    • Optional searchParams: EventSearchParams

      Additional parameters for the query, like ordering, number of rows, etc.

    Returns Promise<StoredEvent[]>


  • isIncomingQueueEmpty(event: Event): boolean
  • Return the state of the incoming queue. True if there are any events(messages) from the user waiting in the queue.


    • event: Event

      Current event in the action context, used to identify the queue

    Returns boolean


  • Register a new middleware globally. They are sorted based on their declared order each time a new one is registered.


    Returns void


  • removeMiddleware(middlewareName: any): void
  • Removes the specified middleware from the chain. This is mostly used in case of a module being reloaded


    • middlewareName: any

    Returns void


  • replyToEvent(eventDestination: EventDestination, payloads: any[], incomingEventId?: undefined | string): void
  • Reply easily to any received event. It accepts an array of payloads and will send a complete event with each payloads. It is often paired with cms.renderElement to generate payload for a specific content type


    • eventDestination: EventDestination

      The destination to identify the target

    • payloads: any[]

      One or multiple payloads to send

    • Optional incomingEventId: undefined | string

    Returns void


  • saveUserFeedback(incomingEventId: string, target: string, feedback: number, type?: undefined | string): Promise<boolean>
  • Register the user feedback for a specific event. The type property is used to increment associated metrics


    • incomingEventId: string

      The ID of the first event of the conversation

    • target: string

      The ID of the user

    • feedback: number

      Either 1 or -1

    • Optional type: undefined | string

      For now, only supports qna & workflow

    Returns Promise<boolean>

    true if feedback was successfully saved


  • sendEvent(event: Event): Promise<void>
  • Send an event through the incoming or outgoing middleware chain


    • event: Event

      The event to send

    Returns Promise<void>


  • updateEvent(id: number, fields: Partial<StoredEvent>): Promise<void>
  • When Event Storage is enabled, you can use this API to update an event. You can use multiple fields for your query, but at least one is required.


    • id: number

      The ID of the event to update

    • fields: Partial<StoredEvent>

      Fields to update on the event

    Returns Promise<void>

Generated using TypeDoc