Developers

Helper Object

Methods

downloadMedia(media)
Downloads a media resource via an Api (AJAX) request and creates the blob in client-side

media Object

  • url String: The URL of the media
  • type String: The content-type of the media
  • name String: The name the media file will have

controlInvitationTTL(inboxElement, ttlElement, invitationExpiration, callback)
Update the element with the TTL provided every second. If the countdown gets to 0, remove the element.

  • inboxElement HTMLElement: HTMLElement that will be removed when the countdown gets to 0
  • ttlElement HTMLElement: HTMLElement where the TTL will be printed and updated
  • invitationExpiration Integer: UNIX time when the invitation expires
  • callback Function: function to execute after the counter has reached 0

getBrowserExpirationTime(serverExpirationTime, timeDifferenceWithServer, ping)
Returns a recalculated expiration time considering the browser time, the server time and the ping between them

  • serverExpirationTime Date: A unix timestamp
  • timeDifferenceWithServer Date: The difference in seconds between the local time and the server time
  • ping Integer: ping in miliseconds

controlChatActiveTime
Update the chat active timer element every second until the chat gets closed

  • chat Chat: Chat object
  • chatTimerElement HTMLElement: element where the timer will be printed and updated
  • acceptedTime Integer: UNIX timestamp when the chat was accepted

monitorUserActivity(input, chat, intervalTime, noChangeMax, errorHandler = null)
Watches an input element for changes and manages and captures activity events

  • input HTMLElement: HTMLElement instance of the chat input
  • chat Chat: Chat instance
  • intervalTime Integer: Interval time to look for input changes
  • noChangeMax Integer: Maximum number of intervals passed to consider that the user is not writing anymore
  • errorHandler Function: Callback that will be executed if an error happens when sending the user activity to the server

getUnixTime()
Get the current time as a UNIX timestamp

addScript(src)
Add a script to the page

  • src: String: The URL of the script

downloadConversation(chatId, props, requestData)
Download a chat conversation as a PDF file

  • chatId String: ID of the chat its conversation will be downloaded

props Object optional

  • template String: Contains an alternative to the default template. The string must be an HTML fulfilling the Vue Template Syntax.
  • labels Object: An object in the vue-i18n format for template labels in different languages.
  • dateTimeFormats Object: An object in the vue-i18n DateTime localization format for date and time formats in different languages.
  • ticketId String: Ticket id that will be shown in the PDF.
  • methods Object: It contains functions that will be available in the custom template.

requestData Object optional: An object to pass additional parameters to the /chats/{chatId}/history request necessary to download the conversation PDF.

isInWorktimeNow(roomId)
Returns a Promise with the result. True if it is in working hours, False if not.

  • roomId Integer: Identifier of the room/queue.

getWorktimeTable(roomId, timezone)
Returns a Promise with timetable and holidays as a result.

  • roomId Integer: Identifier of the room/queue.
  • timezone String: Valid timezone (for example, Europe/Madrid)
  • timetable Array: The defined working hours per day. The key 0 is for Monday, 6 for Sunday. Example:
    "0": [
    {
        "from": "08:00",
        "to": "20:00"
    }
    ],
    "1": [
    {
        "from": "08:00",
        "to": "12:00"
    },
    {
        "from": "15:00",
        "to": "20:00"
    }
    ],
    "6": [
    {
        "from": "00:00",
        "to": "12:00"
    }
    ]
  • holidays Array: The value of the days as integers in the yyyymmdd format:
    "holidays": [
        20230210,
        20230211,
    ],