Chatbot scripts reference

Bot Register

The script name must match the pattern '%bot%register%'.

Input variables

VariableDescription
action”register” / “unregister”
topicidthe ID of the topic the bot is active on

Bot Session Create

The script name must match the pattern '%bot%session%create%'.

Called when a new session starts on a channel with the bot activated.

Input values

ValueDescription
chatSession.idsession has been saved/created at this point
chatSession.topicIdtopic the session belongs to
chatSession.customerAlias
chatSession.sessionKey
chatSession.customerHost
chatSession.statusstate of new session
chatSession.chatbot_isactive”1” (true) for bot sessions
chatTopic.idsame as chatSession.topicId
chatTopic.namename of channel
chatTopic.botNamename of bot
foundAgentsany agents found? Never true for bot channels

Bot Session Change

The script name must match the pattern '%bot%session%change%'.

This script is called when the session changes status (when pre-form is filled in by the customer).

Input values

ValueDescription
chatSession.idsession ID
chatSession.topicIdtopic the session belongs to
chatSession.statusnew status
chatSession.userIdSuperOffice user handling the session
chatSession.customerId
chatSession.botActivealways going to be true
chatSession.customerNameif filled in by pre-form
chatSession.customerEmailif filled in by pre-form
chatSession.companyNameif filled in by pre-form
chatSession.customerPhoneif filled in by pre-form

Variables status.old and status.new contain old and new values for chat session status.

Chat session status values

ValueStatus
0StatusInvalid
1StatusPreChatForm
2StatusFaq
3StatusOfflineForm
4StatusInQueue
5StatusCustomerLast
6StatusUserLast
7StatusFinished
8StatusDeleted
9StatusClosed
10StatusRequestPosted
11StatusClosedFromQueue

Bot Message Receive

The script name must match the pattern '%bot%message%receive%'.

Input values

ValueDescription
chatSession.topicId
chatSession.statuspre-chat form, in-queue, user message, and so on
chatSession.userIdthe SuperOffice user handling the session, not set for bots
chatSession.botActive1 for bots
chatSession.customerNamefrom pre-form
chatSession.customerEmailfrom pre-form
chatSession.companyNamefrom pre-form
chatSession.customerPhonefrom pre-form
chatSession.customerId
chatSession.contactId
chatSession.projectId
chatSession.saleId
chatSession.ticketId
chatMessage.sessionId
chatMessage.id
chatMessage.messagewhat the customer typed
chatMessage.type2 = from the customer, or 3 = special
chatMessage.specialTypeif type = 3
chatMessage.specialParamif type = 3 - Json containing options
chatMessage.authorname shown in chat
chatTopic.id
chatTopic.botName

Bot Post Message

addChatMessage(Integer sessionId, String message, Integer type, String author, Integer specialType, String specialParams, DateTime whenPosted)

Posting a message will set the chat session status to 6 (user last) since the bot was the last to speak.

Reset Chat

resetChat(Integer sessionId)

This starts the session over (session status starts at the beginning again).

Change Status

setChatStatus(sessionId, Integer newStatus)

This changes the session status. This may trigger the session changed event.

Chat message types

ValueType
1ToCustomer
2ToUser
3Special

Chat message special types

ValueType
0None
1Welcome
2Url
3Block
5NewSession
6TransferedSession
7Error
8Deleted
9FaqSuccessQuestion
10ClosedByUser
11ClosedByCustomer
12ClosedByIdle
13TransferRejected
14ReopenedByCustomer
15ClickedOption
17Options
🛈 Note
17 means that the message has a list of clickable options. Options are as JSON array in specialParam.