Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

TemplateItem

TemplateItem: Object | Object[] | string[] | string

Mustache template to render. Can contain objects, arrays, strings.

example

'{{en}}', ['{{nested.de}}'], {notSoNested: '{{fr}}'}

Functions

createOrUpdateContentElement

  • createOrUpdateContentElement(botId: string, contentTypeId: string, formData: object, contentElementId?: undefined | string, language?: undefined | string): Promise<string>
  • Updates an existing content element, or creates it if its current ID isn't defined

    Parameters

    • botId: string

      The ID of the bot

    • contentTypeId: string

      Only used when creating an element (the ID of the content type (renderer))

    • formData: object

      The content of your element. May includes translations or not (see language parameter)

    • Optional contentElementId: undefined | string

      If not specified, will be treated as a new element and will be inserted

    • Optional language: undefined | string

      When language is set, only that language will be updated on this element. Otherwise, replaces all content

    Returns Promise<string>

deleteContentElements

  • deleteContentElements(botId: string, contentElementIds: string[]): Promise<void>
  • Parameters

    • botId: string
    • contentElementIds: string[]

    Returns Promise<void>

getAllContentTypes

  • getAllContentTypes(botId?: undefined | string): Promise<ContentType[]>

getContentElement

  • getContentElement(botId: string, id: string, language?: undefined | string): Promise<ContentElement>
  • Returns a single Content Element

    Parameters

    • botId: string

      The ID of the bot

    • id: string

      The element id

    • Optional language: undefined | string

      If language is set, it will return only the desired language with the base properties

    Returns Promise<ContentElement>

    A content element

getContentElements

  • getContentElements(botId: string, ids: string[], language?: undefined | string): Promise<ContentElement[]>

getFilePath

  • getFilePath(botId: string, fileName: string): string

listContentElements

  • listContentElements(botId: string, contentTypeId?: undefined | string, searchParams?: SearchParams, language?: undefined | string): Promise<ContentElement[]>
  • Parameters

    • botId: string

      The ID of the bot

    • Optional contentTypeId: undefined | string

      Filter entries on that specific content type

    • Optional searchParams: SearchParams

      Additional search parameters (by default, returns 50 elements)

    • Optional language: undefined | string

      When specified, only that language is returned with the original property (ex: text$en becomes text)

    Returns Promise<ContentElement[]>

readFile

  • readFile(botId: any, fileName: any): Promise<Buffer>
  • Parameters

    • botId: any
    • fileName: any

    Returns Promise<Buffer>

renderElement

  • renderElement(contentId: string, args: any, eventDestination: EventDestination): Promise<any[]>
  • Content Types can produce multiple payloads depending on the channel and the type of message. This method can generate payloads for a specific content element or generate them for a custom payload. They can then be sent to the event engine, which sends them through the outgoing middlewares, straight to the user

    example

    const eventDestination = { target: 'user123', botId: 'welcome-bot', channel: 'web', threadId: 1 }

    example

    const payloads = await bp.cms.renderElement('builtin_text', {type: 'text', text: 'hello'}, eventDestination)

    example

    await bp.events.replyToEvent(eventDestination, payloads)

    Parameters

    • contentId: string

      Can be a ContentType (ex: "builtin_text") or a ContentElement (ex: "!builtin_text-s6x5c6")

    • args: any

      Required arguments by the content type (or the content element)

    • eventDestination: EventDestination

      The destination of the payload (to extract the botId and channel)

    Returns Promise<any[]>

    An array of payloads

renderTemplate

  • Render a template using Mustache template rendering. Use recursive template rendering to extract nexted templates.

    Parameters

    • item: TemplateItem

      TemplateItem to render

    • context: any

      Variables to use for the template rendering

    Returns TemplateItem

saveFile

  • saveFile(botId: string, fileName: string, content: Buffer): Promise<string>
  • Parameters

    • botId: string
    • fileName: string
    • content: Buffer

    Returns Promise<string>

Generated using TypeDoc