Type parameters

Hierarchy

Properties

Readonly code

code: string

App code of the URL’s target (the app’s code).

Readonly data

data: Based<Partial<LineSessionData>>

Values of object’s fields.

Readonly fields

fields: Readonly<object>

Description of the object’s fields.

Readonly id

id: string

ID of the URL’s target.

Readonly namespace

namespace: string

Namespace of the URL target (the code of the workspace that the app belongs to).

Methods

assignToBot

  • assignToBot(silent?: undefined | false | true): Promise<void>
  • The method assigns a bot to a session.

    Parameters

    • Optional silent: undefined | false | true

      Parameter that cancels the bot start event (the default value if false).
      The method assigns a session to the bot if there’s a bot connected to the live chat.

      await Context.data.session.assignToBot();
      

    Returns Promise<void>

assignToOperator

  • assignToOperator(operator: UserItemRef): Promise<void>
  • The method assigns an operator to a session.

    Parameters

    • operator: UserItemRef

      Operator.

      await Context.data.session.assignToOperator(Context .data.user);
      

    Returns Promise<void>

assignToOperatorGroup

  • The method assigns a group of operators to a session.

    Parameters

    • userGroup: UserGroupItemRef

      Operator group. It has to be added to the Live Chat operators list.

      await Context.data.session.assignToOperatorGroup(Context.data. userGroup);
      

    Returns Promise<void>

close

  • close(): Promise<void>
  • The method is used to close an active session.

    await Context.data.session.close();
    

    Returns Promise<void>

fetch

getAllMessages

  • getAllMessages(from?: undefined | number, size?: undefined | number): Promise<LineMessageItem[]>
  • The method returns all messages in a session.

    Parameters

    • Optional from: undefined | number

      Number of entries to skip (the default value is 0).

    • Optional size: undefined | number

      Number of search results (the default number is 10, the maximum is 10,000).

      // Get the first one hundred messages in a session 
      const  messages = await Context.data.session.getAllMessages(0, 100); 
      

    Returns Promise<LineMessageItem[]>

getLastMessage

  • The method returns the last message in a session.

    const lastMessage = await Context.data.session. getLastMessage();
    

    Returns Promise<LineMessageItem>

markAsSpam

  • markAsSpam(): Promise<void>
  • The method marks a session as spam.

    The data (metrics) of a session marked as spam are not taken into account when generating reports. The method is not available for the following types of channels: internal and support (see LineChannelType).

    await Context.data.session.markAsSpam();
    

    Returns Promise<void>

normalize

  • normalize(): void
  • Delete duplicate data in arrays.

    The method deletes duplicates in fields that store arrays of links to system objects (users, files, app items, or documents). For example, you can call this method after bulk editing data within an object.

    const  app1 = await Context.data.app1.fetch();
    const app2 = await Context.data.app2 .fetch(); 
    app1.data.executors.push(app2.data.executors); 
    app1.normalize();  
    // Now we need to go over the elements in the new array 
    app1.data.executors .forEach( ... ); 
    

    Returns void

save

  • save(): Promise<void>
  • The method saves the session object.

    This method is used to update the current session. The following fields are editable: __name and _apps.

        const session = await  Context.data.session.fetch();
        session.data.__name = 'new session name';  
        session.data._apps.push(Context.data.lead); 
        await session.save();  
    

    Returns Promise<void>

sendSystemMessage

  • The method sends a system message to a session.

    Parameters

    • message: string

      A message in the form of text of HTML.

      const message =  Context.data.session.sendSystemMessage('Priority changed to High');
      

    Returns Promise<LineMessageItem>

setPriority

  • The method is used to set a session’s priority.

    await Context.data.session.setPriority(LineSessionPriority. Low);
    

    Parameters

    Returns Promise<void>

unmarkAsSpam

  • unmarkAsSpam(): Promise<void>
  • The method deletes a session from spam.

    The session is assigned to the operator who previously worked on it or added to the queue.

    await Context.data.session.unmarkAsSpam();
    

    Returns Promise<void>