Bitrix API

Network extends Base implements NetworkBot

Table of Contents

Interfaces

NetworkBot

Constants

BOT_CODE  = "network"
BUTTON_DEFAULT_COLOR  = '#29619b'
BUTTON_DISABLED_COLOR  = '#aaa'
CHAT_ENTITY_TYPE  = 'NETWORK_DIALOG'
CHAT_NETWORK_SUPPORT_COUNTER  = 'imbot_network_dialog_'
CHAT_NETWORK_SUPPORT_MAX_DIALOGS_OPTION  = 'network_dialogs_max_count_'
COMMAND_CHECK_PUBLIC_URL  = 'checkPublicUrl'
COMMAND_CONNECTOR_REGISTER  = 'RegisterConnector'
COMMAND_CONNECTOR_UNREGISTER  = 'UnRegisterConnector'
COMMAND_CONNECTOR_UPDATE  = 'UpdateConnector'
COMMAND_FINISH_DIALOG_SESSION  = 'finishDialogSession'
COMMAND_NETWORK_SESSION  = 'session'
COMMAND_OPERATOR_CHANGE_LINE  = 'operatorChangeLine'
COMMAND_OPERATOR_MESSAGE_ADD  = 'operatorMessageAdd'
COMMAND_OPERATOR_MESSAGE_DELETE  = 'operatorMessageDelete'
COMMAND_OPERATOR_MESSAGE_RECEIVED  = 'operatorMessageReceived'
COMMAND_OPERATOR_MESSAGE_UPDATE  = 'operatorMessageUpdate'
COMMAND_OPERATOR_OPEN_NEW_DIALOG  = 'operatorOpenNewDialog'
COMMAND_OPERATOR_START_WRITING  = 'operatorStartWriting'
COMMAND_START_DIALOG_SESSION  = 'startDialogSession'
COMMAND_UNREGISTER  = 'unregister'
MESSAGE_PARAM_ALLOW_QUOTE  = 'IMOL_QUOTE_MSG'
MESSAGE_PARAM_ATTACH  = 'ATTACH'
MESSAGE_PARAM_CONNECTOR_MID  = 'CONNECTOR_MID'
MESSAGE_PARAM_DELIVERED  = 'IS_DELIVERED'
MESSAGE_PARAM_IMOL_VOTE  = 'IMOL_VOTE'
MESSAGE_PARAM_IMOL_VOTE_DISLIKE  = 'IMOL_VOTE_DISLIKE'
MESSAGE_PARAM_IMOL_VOTE_LIKE  = 'IMOL_VOTE_LIKE'
MESSAGE_PARAM_KEYBOARD  = 'KEYBOARD'
MESSAGE_PARAM_SENDING  = 'SENDING'
MESSAGE_PARAM_SENDING_TIME  = 'SENDING_TS'
MESSAGE_PARAM_SESSION_ID  = 'IMOL_SID'
MODULE_ID  = "imbot"
MULTIDIALOG_STATUS_CLOSE  = 'CLOSE'
MULTIDIALOG_STATUS_NEW  = 'NEW'
MULTIDIALOG_STATUS_OPEN  = 'OPEN'
PORTAL_PATH  = '/pub/imbot.php'
SUPPORT_LEVEL_FREE  = 'free'
SUPPORT_LEVEL_NONE  = 'none'
SUPPORT_LEVEL_PAID  = 'paid'
SUPPORT_LEVEL_PARTNER  = 'partner'

Methods

addAgent()  : bool
Adds agent.
addError()  : void
addNetworkQuestionByBotId()  : int
allowAdditionalQuestion()  : bool
checkCodeBlacklist()  : bool
checkPublicUrl()  : bool
Checks availability of the external public url.
checkSessionVoteMessage()  : bool
Performs checking if it is user voting for session by direct text input '1' or '0'.
cleanQuestionsCountCache()  : void
clientMessageAdd()  : bool|array<string|int, mixed>
Sends new client message into network line.
delayShowingMessage()  : bool
deleteAgent()  : bool
Removes agents.
deleteScheduledAction()  : void
getAccessLevel()  : string
Detects client's support level.
getAdministrators()  : array<string|int, int>
List of administrator users.
getAllQuestions()  : array<string|int, mixed>
getAppList()  : array<string|int, array{command: string, icon: string, js: string, context: string, lang: string}>
Returns app's property list.
getBotAsMultidialog()  : mixed
getBotCode()  : string
Returns OL code.
getBotId()  : int
Returns registered bot Id.
getBotSettings()  : array<string|int, mixed>|null
Loads bot settings from controller.
getBusinessUsers()  : array<string|int, int>
List of unlimited users.
getChatWithBot()  : array<string|int, mixed>|null
getCommandList()  : array<string|int, array{class: string, handler: string, visible: bool, context: string}>
Returns command's property list.
getError()  : Error
getEventHandlerList()  : array<string|int, array{module: string, event: string, class: string, handler: string}>
Returns event handler list.
getLangMessage()  : string
Returns phrase according its code.
getMultidialog()  : array<string|int, mixed>|null
getNetworkBotId()  : bool|int
Returns open line bot id.
getQuestionLimit()  : int
Returns the limit for additional questions.
getQuestionList()  : array<string|int, mixed>
getQuestionsCount()  : int
getQuestionsWithUnreadMessages()  : array<string|int, mixed>
getRecentDialogs()  : Generator|iterable<string|int, mixed>
Returns bot's recent dialogs.
getSupportLevel()  : string
getUserGeoData()  : string
Collects some available geo data.
hasError()  : bool
Tells true if error has occurred.
incrementGlobalDialogCounter()  : int
initHttpClient()  : Http
Replace web client.
isEnabled()  : bool
Is bot enabled.
isFdcCode()  : bool
isNeedUpdateBotAvatarAfterNewMessage()  : bool
Allows updating bot's avatar using data from incoming message.
isNeedUpdateBotFieldsAfterNewMessage()  : bool
Allows updating bot fields (name, desc, avatar, welcome mess) using data from incoming message.
isUserAdmin()  : bool
Checks if user has an portal administrator access role.
isUserIntegrator()  : bool
Checks if user has an integrator access role.
join()  : bool|int
Check if network bot exists and registers it.
onAnswerAdd()  : array<string|int, mixed>|Error
Event handler on answer add.
onBotDelete()  : bool
Event handler on bot remove.
onChatStart()  : bool
Event handler when bot join to chat.
onCommandAdd()  : bool
Event handler on command add.
onCommandLang()  : bool|array<string|int, mixed>
Returns title and description for app or command list.
onLocalCommandAdd()  : mixed
Compatibility alias to the onCommandAdd method.
onMessageAdd()  : bool
Event handler on message add.
onMessageDelete()  : bool
onMessageUpdate()  : bool
onReceiveCommand()  : Error|array<string|int, mixed>
Event handler on answer add.
onSessionVote()  : bool
Handler for "im:OnSessionVote" event.
onStartWriting()  : bool
register()  : bool|int|string
Register bot at portal.
registerApps()  : bool
Register bot's command.
registerCommands()  : bool
Register bot's command.
registerConnector()  : array<string|int, mixed>|bool
replacePlaceholders()  : string
Replaces standard placeholders.
scheduleAction()  : void
scheduledActionAgent()  : string
search()  : bool|array<string|int, mixed>
Looks for the network openline.
sendMessage()  : array<string|int, mixed>
Sends message to client.
sendNotifyChangeLicence()  : bool
Sends notify change licence.
sendRequestFinalizeSession()  : bool
Sends finalize session notification.
sendUnregisterRequest()  : bool
Sends unregister bot request.
setBotId()  : bool
Saves new Id of the registered bot.
setNetworkBotId()  : bool
Saves new open line bot id.
setQuestionLimit()  : void
Returns the limit for additional questions.
unRegister()  : bool
Unregister bot at portal.
unRegisterConnector()  : bool|array<string|int, mixed>
updateConnector()  : bool|array<string|int, mixed>
uploadAvatar()  : array<string|int, mixed>|string
Dowlloads user avatar via supplied image url.
uploadIcon()  : bool|int

Constants

BOT_CODE

public mixed BOT_CODE = "network"

BUTTON_DEFAULT_COLOR

public mixed BUTTON_DEFAULT_COLOR = '#29619b'

BUTTON_DISABLED_COLOR

public mixed BUTTON_DISABLED_COLOR = '#aaa'

CHAT_ENTITY_TYPE

public mixed CHAT_ENTITY_TYPE = 'NETWORK_DIALOG'

CHAT_NETWORK_SUPPORT_COUNTER

public mixed CHAT_NETWORK_SUPPORT_COUNTER = 'imbot_network_dialog_'

CHAT_NETWORK_SUPPORT_MAX_DIALOGS_OPTION

public mixed CHAT_NETWORK_SUPPORT_MAX_DIALOGS_OPTION = 'network_dialogs_max_count_'

COMMAND_CHECK_PUBLIC_URL

public mixed COMMAND_CHECK_PUBLIC_URL = 'checkPublicUrl'

COMMAND_CONNECTOR_REGISTER

public mixed COMMAND_CONNECTOR_REGISTER = 'RegisterConnector'

COMMAND_CONNECTOR_UNREGISTER

public mixed COMMAND_CONNECTOR_UNREGISTER = 'UnRegisterConnector'

COMMAND_CONNECTOR_UPDATE

public mixed COMMAND_CONNECTOR_UPDATE = 'UpdateConnector'

COMMAND_FINISH_DIALOG_SESSION

public mixed COMMAND_FINISH_DIALOG_SESSION = 'finishDialogSession'

COMMAND_NETWORK_SESSION

public mixed COMMAND_NETWORK_SESSION = 'session'

COMMAND_OPERATOR_CHANGE_LINE

public mixed COMMAND_OPERATOR_CHANGE_LINE = 'operatorChangeLine'

COMMAND_OPERATOR_MESSAGE_ADD

public mixed COMMAND_OPERATOR_MESSAGE_ADD = 'operatorMessageAdd'

COMMAND_OPERATOR_MESSAGE_DELETE

public mixed COMMAND_OPERATOR_MESSAGE_DELETE = 'operatorMessageDelete'

COMMAND_OPERATOR_MESSAGE_RECEIVED

public mixed COMMAND_OPERATOR_MESSAGE_RECEIVED = 'operatorMessageReceived'

COMMAND_OPERATOR_MESSAGE_UPDATE

public mixed COMMAND_OPERATOR_MESSAGE_UPDATE = 'operatorMessageUpdate'

COMMAND_OPERATOR_OPEN_NEW_DIALOG

public mixed COMMAND_OPERATOR_OPEN_NEW_DIALOG = 'operatorOpenNewDialog'

COMMAND_OPERATOR_START_WRITING

public mixed COMMAND_OPERATOR_START_WRITING = 'operatorStartWriting'

COMMAND_START_DIALOG_SESSION

public mixed COMMAND_START_DIALOG_SESSION = 'startDialogSession'

COMMAND_UNREGISTER

public mixed COMMAND_UNREGISTER = 'unregister'

MESSAGE_PARAM_ALLOW_QUOTE

public mixed MESSAGE_PARAM_ALLOW_QUOTE = 'IMOL_QUOTE_MSG'

MESSAGE_PARAM_ATTACH

public mixed MESSAGE_PARAM_ATTACH = 'ATTACH'

MESSAGE_PARAM_CONNECTOR_MID

public mixed MESSAGE_PARAM_CONNECTOR_MID = 'CONNECTOR_MID'

MESSAGE_PARAM_DELIVERED

public mixed MESSAGE_PARAM_DELIVERED = 'IS_DELIVERED'

MESSAGE_PARAM_IMOL_VOTE

public mixed MESSAGE_PARAM_IMOL_VOTE = 'IMOL_VOTE'

MESSAGE_PARAM_IMOL_VOTE_DISLIKE

public mixed MESSAGE_PARAM_IMOL_VOTE_DISLIKE = 'IMOL_VOTE_DISLIKE'

MESSAGE_PARAM_IMOL_VOTE_LIKE

public mixed MESSAGE_PARAM_IMOL_VOTE_LIKE = 'IMOL_VOTE_LIKE'

MESSAGE_PARAM_KEYBOARD

public mixed MESSAGE_PARAM_KEYBOARD = 'KEYBOARD'

MESSAGE_PARAM_SENDING

public mixed MESSAGE_PARAM_SENDING = 'SENDING'

MESSAGE_PARAM_SENDING_TIME

public mixed MESSAGE_PARAM_SENDING_TIME = 'SENDING_TS'

MESSAGE_PARAM_SESSION_ID

public mixed MESSAGE_PARAM_SESSION_ID = 'IMOL_SID'

MODULE_ID

public mixed MODULE_ID = "imbot"

MULTIDIALOG_STATUS_CLOSE

public mixed MULTIDIALOG_STATUS_CLOSE = 'CLOSE'

MULTIDIALOG_STATUS_NEW

public mixed MULTIDIALOG_STATUS_NEW = 'NEW'

MULTIDIALOG_STATUS_OPEN

public mixed MULTIDIALOG_STATUS_OPEN = 'OPEN'

PORTAL_PATH

public mixed PORTAL_PATH = '/pub/imbot.php'

SUPPORT_LEVEL_FREE

public mixed SUPPORT_LEVEL_FREE = 'free'

SUPPORT_LEVEL_NONE

public mixed SUPPORT_LEVEL_NONE = 'none'

SUPPORT_LEVEL_PAID

public mixed SUPPORT_LEVEL_PAID = 'paid'

SUPPORT_LEVEL_PARTNER

public mixed SUPPORT_LEVEL_PARTNER = 'partner'

Methods

addAgent()

Adds agent.

public static addAgent(array{agent: string, class: string, next_execution: string, delay: int, regular: bool, interval: int} $params) : bool
Parameters
$params : array{agent: string, class: string, next_execution: string, delay: int, regular: bool, interval: int}
Tags
throws
ArgumentException
Return values
bool

addError()

public static addError(Error $error) : void
Parameters
$error : Error

addNetworkQuestionByBotId()

public static addNetworkQuestionByBotId(int $botId[, int|null $userId = null ]) : int
Parameters
$botId : int
$userId : int|null = null
Return values
int

allowAdditionalQuestion()

public static allowAdditionalQuestion([int|null $botId = null ]) : bool
Parameters
$botId : int|null = null
Return values
bool

checkCodeBlacklist()

public static checkCodeBlacklist(string $code) : bool
Parameters
$code : string
Return values
bool

checkPublicUrl()

Checks availability of the external public url.

public static checkPublicUrl([string $publicUrl = null ]) : bool
Parameters
$publicUrl : string = null

Portal public url.

Tags
see
CheckPublicUrl
Return values
bool

checkSessionVoteMessage()

Performs checking if it is user voting for session by direct text input '1' or '0'.

public static checkSessionVoteMessage(array<string|int, mixed> $messageFields) : bool
Parameters
$messageFields : array<string|int, mixed>

Message arguments.

Return values
bool

cleanQuestionsCountCache()

public static cleanQuestionsCountCache([int|null $botId = null ]) : void
Parameters
$botId : int|null = null

clientMessageAdd()

Sends new client message into network line.

public static clientMessageAdd(array<string|int, mixed> $fields) : bool|array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

Command arguments.

[
	(int) USER_ID
	(int|string) DIALOG_ID
	(string|array) MESSAGE
	(int) BOT_ID
	(array) FILES
	(array) ATTACH
	(array) PARAMS
]
Tags
see
ClientMessageAdd
Return values
bool|array<string|int, mixed>

delayShowingMessage()

public static delayShowingMessage(mixed $botId, array<string|int, mixed> $messageFields) : bool
Parameters
$botId : mixed
$messageFields : array<string|int, mixed>
Return values
bool

deleteAgent()

Removes agents.

public static deleteAgent(array{agent: string, mask: string, class: string} $params) : bool
Parameters
$params : array{agent: string, mask: string, class: string}
Tags
throws
ArgumentException
Return values
bool

deleteScheduledAction()

public static deleteScheduledAction([string $target = '' ][, string $action = '' ][, string $code = '' ]) : void
Parameters
$target : string = ''
$action : string = ''
$code : string = ''

getAccessLevel()

Detects client's support level.

public static getAccessLevel() : string
Return values
string

getAdministrators()

List of administrator users.

public static getAdministrators() : array<string|int, int>
Return values
array<string|int, int>

getAllQuestions()

public static getAllQuestions([int|null $botId = null ][, int|null $userId = null ]) : array<string|int, mixed>
Parameters
$botId : int|null = null
$userId : int|null = null
Return values
array<string|int, mixed>

getAppList()

Returns app's property list.

public static getAppList() : array<string|int, array{command: string, icon: string, js: string, context: string, lang: string}>
Return values
array<string|int, array{command: string, icon: string, js: string, context: string, lang: string}>

getBotAsMultidialog()

public static getBotAsMultidialog(int $botId, int $userId) : mixed
Parameters
$botId : int
$userId : int

getBotCode()

Returns OL code.

public static getBotCode() : string
Return values
string

getBotId()

Returns registered bot Id.

public static getBotId() : int
Return values
int

getBotSettings()

Loads bot settings from controller.

public static getBotSettings([array{BOT_ID: int, PORTAL_TARIFF: string} $params = [] ]) : array<string|int, mixed>|null
Parameters
$params : array{BOT_ID: int, PORTAL_TARIFF: string} = []

Command arguments.

Tags
see
SettingsSupport
Return values
array<string|int, mixed>|null

getBusinessUsers()

List of unlimited users.

public static getBusinessUsers() : array<string|int, int>
Tags
see
CBitrix24BusinessTools::getUnlimUsers
Return values
array<string|int, int>

getChatWithBot()

public static getChatWithBot([int|null $botId = null ][, int|null $userId = null ]) : array<string|int, mixed>|null
Parameters
$botId : int|null = null
$userId : int|null = null
Return values
array<string|int, mixed>|null

getCommandList()

Returns command's property list.

public static getCommandList() : array<string|int, array{class: string, handler: string, visible: bool, context: string}>
Return values
array<string|int, array{class: string, handler: string, visible: bool, context: string}>

getError()

public static getError() : Error
Return values
Error

getEventHandlerList()

Returns event handler list.

public static getEventHandlerList() : array<string|int, array{module: string, event: string, class: string, handler: string}>
Return values
array<string|int, array{module: string, event: string, class: string, handler: string}>

getLangMessage()

Returns phrase according its code.

public static getLangMessage([string $messageCode = '' ]) : string
Parameters
$messageCode : string = ''

Phrase code.

Return values
string

getMultidialog()

public static getMultidialog(int $chatId[, int|null $botId = null ][, int|null $userId = null ]) : array<string|int, mixed>|null
Parameters
$chatId : int
$botId : int|null = null
$userId : int|null = null
Return values
array<string|int, mixed>|null

getNetworkBotId()

Returns open line bot id.

public static getNetworkBotId(string $code[, bool $getFromDb = false ]) : bool|int
Parameters
$code : string

Line code.

$getFromDb : bool = false

Do not use Main\Config\Option to detect it.

Return values
bool|int

getQuestionLimit()

Returns the limit for additional questions.

public static getQuestionLimit([int|null $botId = null ]) : int
Parameters
$botId : int|null = null
Return values
int

-1 - Functional is disabled, 0 - There is no limit, n - Max number for sessions allowed.

getQuestionList()

public static getQuestionList(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
Return values
array<string|int, mixed>

getQuestionsCount()

public static getQuestionsCount([int|null $botId = null ][, int|null $userId = null ]) : int
Parameters
$botId : int|null = null
$userId : int|null = null
Return values
int

getQuestionsWithUnreadMessages()

public static getQuestionsWithUnreadMessages([int|null $botId = null ]) : array<string|int, mixed>
Parameters
$botId : int|null = null
Return values
array<string|int, mixed>

getRecentDialogs()

Returns bot's recent dialogs.

public static getRecentDialogs([int $hoursDepth = 168 ][, int|null $botId = null ]) : Generator|iterable<string|int, mixed>
Parameters
$hoursDepth : int = 168

Depth into past. Default: 7 days.

$botId : int|null = null
Return values
Generator|iterable<string|int, mixed>
[
  0 => [
     (int) USER_ID
     (int) CHAT_ID
     (string) RECENTLY_TALK
     (int) MESSAGE_ID
  ],
  ...

getSupportLevel()

public static getSupportLevel() : string
Return values
string

getUserGeoData()

Collects some available geo data.

public static getUserGeoData() : string
Return values
string

hasError()

Tells true if error has occurred.

public static hasError() : bool
Return values
bool

incrementGlobalDialogCounter()

public static incrementGlobalDialogCounter(int $botId) : int
Parameters
$botId : int
Return values
int

initHttpClient()

Replace web client.

public static initHttpClient(Http $httpClient) : Http
Parameters
$httpClient : Http
Return values
Http

isEnabled()

Is bot enabled.

public static isEnabled() : bool
Return values
bool

isFdcCode()

public static isFdcCode(string $text) : bool
Parameters
$text : string
Return values
bool

isNeedUpdateBotAvatarAfterNewMessage()

Allows updating bot's avatar using data from incoming message.

public static isNeedUpdateBotAvatarAfterNewMessage() : bool
Return values
bool

isNeedUpdateBotFieldsAfterNewMessage()

Allows updating bot fields (name, desc, avatar, welcome mess) using data from incoming message.

public static isNeedUpdateBotFieldsAfterNewMessage() : bool
Return values
bool

isUserAdmin()

Checks if user has an portal administrator access role.

public static isUserAdmin(int $userId) : bool
Parameters
$userId : int
Return values
bool

isUserIntegrator()

Checks if user has an integrator access role.

public static isUserIntegrator(int $userId) : bool
Parameters
$userId : int
Return values
bool

join()

Check if network bot exists and registers it.

public static join(string $code[, array<string|int, mixed> $options = [] ]) : bool|int
Parameters
$code : string

Open line code.

$options : array<string|int, mixed> = []

Additional bot user parameters.

Return values
bool|int

onAnswerAdd()

Event handler on answer add.

public static onAnswerAdd(string $command, array<string|int, mixed> $params) : array<string|int, mixed>|Error
Parameters
$command : string

Text command alias.

$params : array<string|int, mixed>

Command arguments.

Return values
array<string|int, mixed>|Error

onBotDelete()

Event handler on bot remove.

public static onBotDelete([int|null $bodId = null ]) : bool
Parameters
$bodId : int|null = null
Return values
bool

onChatStart()

Event handler when bot join to chat.

public static onChatStart(string $dialogId, array<string|int, mixed> $joinFields) : bool
Parameters
$dialogId : string

Dialog Id.

$joinFields : array<string|int, mixed>

Event arguments.

Return values
bool

onCommandAdd()

Event handler on command add.

public static onCommandAdd(int $messageId, array<string|int, mixed> $messageFields) : bool
Parameters
$messageId : int

Message Id.

$messageFields : array<string|int, mixed>

Event arguments.

[
	(string) COMMAND
	(string) COMMAND_PARAMS
	(string) COMMAND_CONTEXT == KEYBOARD
	(int) COMMAND_ID
	(string) MESSAGE_TYPE == P
	(string) SYSTEM != Y
	(int) TO_USER_ID
	(int) FROM_USER_ID
	(int) CONNECTOR_MID
]
Return values
bool

onCommandLang()

Returns title and description for app or command list.

public static onCommandLang(string $command[, string $lang = null ]) : bool|array<string|int, mixed>
Parameters
$command : string

App or command code.

$lang : string = null

Language Id.

Return values
bool|array<string|int, mixed>

onLocalCommandAdd()

Compatibility alias to the onCommandAdd method.

public static onLocalCommandAdd(mixed $messageId, mixed $messageFields) : mixed
Parameters
$messageId : mixed
$messageFields : mixed
Tags
todo

Remove it.

onMessageAdd()

Event handler on message add.

public static onMessageAdd(int $messageId, array<string|int, mixed> $messageFields) : bool
Parameters
$messageId : int

Message Id.

$messageFields : array<string|int, mixed>

Event arguments.

[
	(int) BOT_ID
	(int) CHAT_ID
	(int) FROM_USER_ID
	(string) DIALOG_ID
	(string) MESSAGE_TYPE
	(string) MESSAGE
	(string) SYSTEM = Y|N
	(array) FILES
	(array) PARAMS
]
Tags
see
Bot::onMessageAdd
Return values
bool

onMessageDelete()

public static onMessageDelete(int $messageId, array<string|int, mixed> $messageFields) : bool
Parameters
$messageId : int

Message Id.

$messageFields : array<string|int, mixed>

Event arguments.

Return values
bool

onMessageUpdate()

public static onMessageUpdate(int $messageId, array<string|int, mixed> $messageFields) : bool
Parameters
$messageId : int

Message Id.

$messageFields : array<string|int, mixed>

Event arguments.

Return values
bool

onReceiveCommand()

Event handler on answer add.

public static onReceiveCommand(string $command, array<string|int, mixed> $params) : Error|array<string|int, mixed>

Alias for @see \Bitrix\Imbot\Bot\ChatBot::onAnswerAdd Called from @see \Bitrix\ImBot\Controller::sendToBot

Parameters
$command : string

Text command alias.

$params : array<string|int, mixed>

Command arguments.

[
	(int) MESSAGE_ID
	(int) SESSION_ID
	(int) BOT_ID
	(string) BOT_CODE
	(string) DIALOG_ID
	(string) MESSAGE
	(array) FILES
	(array) ATTACH
	(array) KEYBOARD
	(array) PARAMS
	(array) USER
	(array) LINE
	(int) CONNECTOR_MID
]
Return values
Error|array<string|int, mixed>

onSessionVote()

Handler for "im:OnSessionVote" event.

public static onSessionVote(array<string|int, mixed> $params) : bool
Parameters
$params : array<string|int, mixed>

Event arguments.

Return values
bool

onStartWriting()

public static onStartWriting(array<string|int, mixed> $params) : bool
Parameters
$params : array<string|int, mixed>

Event arguments.

Tags
see
Event::onStartWriting
Return values
bool

register()

Register bot at portal.

public static register([array<string|int, mixed> $params = [] ]) : bool|int|string
Parameters
$params : array<string|int, mixed> = []

Command arguments.

[
	(string) CODE
	(string) LINE_NAME
	(string) LINE_DESC
	(string) LINE_AVATAR
	(string) LINE_WELCOME_MESSAGE
	(string) AGENT Agent mode - Y|N
	(array) OPTIONS
	(string) OPTIONS['TYPE']
	(string) OPTIONS['PARTNER_NAME']
]
Tags
see
RegisterBot
Return values
bool|int|string

registerApps()

Register bot's command.

public static registerApps([int|null $botId = null ]) : bool
Parameters
$botId : int|null = null
Return values
bool

registerCommands()

Register bot's command.

public static registerCommands([int|null $botId = null ]) : bool
Parameters
$botId : int|null = null
Return values
bool

registerConnector()

public static registerConnector(int $lineId[, array<string|int, mixed> $fields = [] ]) : array<string|int, mixed>|bool
Parameters
$lineId : int
$fields : array<string|int, mixed> = []
Return values
array<string|int, mixed>|bool

replacePlaceholders()

Replaces standard placeholders.

public static replacePlaceholders(string $message[, int $userId = 0 ]) : string
Parameters
$message : string
$userId : int = 0
Return values
string

scheduleAction()

public static scheduleAction(string $target, string $action[, string $code = '' ][, int $delayMinutes = 1 ]) : void
Parameters
$target : string
$action : string
$code : string = ''
$delayMinutes : int = 1

scheduledActionAgent()

public static scheduledActionAgent(string $target, string $action[, string $code = '' ]) : string
Parameters
$target : string
$action : string
$code : string = ''
Return values
string

Looks for the network openline.

public static search(string $text[, bool $doNotCheckBlackList = false ]) : bool|array<string|int, mixed>
Parameters
$text : string

Search string. Openline's name or exact code.

$doNotCheckBlackList : bool = false
Tags
see
ClientSearchLine
Return values
bool|array<string|int, mixed>

Command arguments.

[
	0 => [
		(string) CODE,
		(string) LINE_NAME,
		(string) LINE_DESC,
		(string) LINE_WELCOME_MESSAGE,
		(string) LINE_AVATAR,
		(bool) VERIFIED,
	],
	...

sendMessage()

Sends message to client.

public static sendMessage(array<string|int, mixed> $messageFields) : array<string|int, mixed>
Parameters
$messageFields : array<string|int, mixed>

Command arguments.

[
	(int) TO_USER_ID
	(int) FROM_USER_ID
	(string) DIALOG_ID
	(array) PARAMS
	(string) MESSAGE
	(array | \CIMMessageParamAttach) ATTACH
	(array | Keyboard) KEYBOARD
	(string) SYSTEM - N|Y
	(string) URL_PREVIEW  - N|Y
]
Return values
array<string|int, mixed>

sendNotifyChangeLicence()

Sends notify change licence.

public static sendNotifyChangeLicence(array<string|int, mixed> $params) : bool
Parameters
$params : array<string|int, mixed>

Command arguments.

[
	(string) PREVIOUS_LICENCE_TYPE
	(string) PREVIOUS_LICENCE_NAME
	(string) CURRENT_LICENCE_TYPE
	(string) CURRENT_LICENCE_NAME
	(string) PREVIOUS_BOT_CODE
	(string) CURRENT_BOT_CODE
	(string) MESSAGE
]
Tags
see
ClientChangeLicence
Return values
bool

sendRequestFinalizeSession()

Sends finalize session notification.

public static sendRequestFinalizeSession([array<string|int, mixed> $params = [] ]) : bool
Parameters
$params : array<string|int, mixed> = []

Command arguments.

[
	(string) LICENSE_TYPE
	(string) LICENSE_NAME
	(string) BOT_CODE
	(string) MESSAGE
]
Tags
see
ClientRequestFinalizeSession
Return values
bool

sendUnregisterRequest()

Sends unregister bot request.

public static sendUnregisterRequest(string $code, int $botId) : bool
Parameters
$code : string

Open line code.

$botId : int

Bot id.

Tags
see
UnRegisterBot
Return values
bool

setBotId()

Saves new Id of the registered bot.

public static setBotId(int $id) : bool
Parameters
$id : int
Return values
bool

setNetworkBotId()

Saves new open line bot id.

public static setNetworkBotId(string $lineCode, int $botId) : bool
Parameters
$lineCode : string

Line code.

$botId : int

Bot Id.

Return values
bool

setQuestionLimit()

Returns the limit for additional questions.

public static setQuestionLimit(int $limit[, int|null $botId = null ]) : void
Parameters
$limit : int

-1 - Functional is disabled, 0 - There is no limit, n - Max number for sessions allowed.

$botId : int|null = null

unRegister()

Unregister bot at portal.

public static unRegister([string $code = '' ][, bool $notifyController = true ]) : bool
Parameters
$code : string = ''

Open Line Id.

$notifyController : bool = true

Send unregister notification request to controller.

Return values
bool

unRegisterConnector()

public static unRegisterConnector(int $lineId) : bool|array<string|int, mixed>
Parameters
$lineId : int
Return values
bool|array<string|int, mixed>

updateConnector()

public static updateConnector(int $lineId, array<string|int, mixed> $fields) : bool|array<string|int, mixed>
Parameters
$lineId : int
$fields : array<string|int, mixed>
Return values
bool|array<string|int, mixed>

uploadAvatar()

Dowlloads user avatar via supplied image url.

public static uploadAvatar([string $avatarUrl = '' ][, string $hash = '' ]) : array<string|int, mixed>|string
Parameters
$avatarUrl : string = ''

Image url.

$hash : string = ''

Salt string for auto naming.

Return values
array<string|int, mixed>|string

uploadIcon()

public static uploadIcon(mixed $iconName) : bool|int
Parameters
$iconName : mixed
Return values
bool|int

        
On this page

Search results