Skip to main content
Version: 2.0.0

Plugin

LCMessager

Laiye CAIP's dialogue interface, including message sending and receiving, message rendering, user registration, interface authentication, input suggestion, etc.

Configurable parameters

type LCMeesagerConfig = {
// required
// agentId
agentId: string
// channelId
channelId: string
// serviceAccountId
serviceAccountId: string
// serviceAccountSecret
serviceAccountSecret: string
// historyChannelId
historyChannelId?: string
// running environment. default: 'PRODUCT'
env?: 'PRODUCT' | 'SKETCH'
// add interface authentication header for each request or not. default: true
needSign?: boolean
// ---------------------------
// optional
// request config
request?: {
// request base url. default: ''
baseUrl: string
}

// message generator. default: defaultGenMessages
genMessages?: (message: FormatedMessage[]) => Message[]

// send welcome message or not. default: true
sendWelcomeMsg?: boolean

// get history messages or not. default: true
getHistory?: boolean

// create user during initial or not. The registered user name is model.userInfo.name. default: false
createUser?: boolean
}

System events

didInitial

  • payload: -
  • preset callback:
    1. When env equals to true or createUser is true, check whether the current user exists, create if not.
    2. Check whether the current channel is LC. If not, end the callback.
    3. If getHistory is true, fetch and render history messages.
    4. If sendWelcomeMsg is true, a greeting is sent.

sendUserMessage

  • payload:
    type payload = {
    type: 'text'
    content: any
    appendUserMessage: boolean // default: true
    appendReciveMessage: boolean // default: true
    setQuickReplies: boolean // default: true
    setIsTyping: boolean // default: true
    }
  • preset callback: Call the LC getReply interface to send a message.

clickQuickReply

  • payload:
    type payload = {
    item: QuickReply
    index: number
    }
  • preset callback: If the type is text, emit sendUserMessage event.