Bitrix API

ChatBot

Common interface for chat bots.

Table of Contents

Methods

getBotId()  : int
Returns registered bot Id.
getError()  : Error
isEnabled()  : bool
Is bot enabled.
onAnswerAdd()  : array<string|int, mixed>
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.
onMessageAdd()  : bool
Event handler on message add.
register()  : int
Register bot at portal.
unRegister()  : bool
Unregister bot at portal.

Methods

getBotId()

Returns registered bot Id.

public static getBotId() : int
Return values
int

getError()

public static getError() : Error
Return values
Error

isEnabled()

Is bot enabled.

public static isEnabled() : bool
Return values
bool

onAnswerAdd()

Event handler on answer add.

public static onAnswerAdd(string $command, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$command : string
$params : array<string|int, mixed>
Tags
see
Controller::sendToBot
Return values
array<string|int, mixed>

onBotDelete()

Event handler on bot remove.

public static onBotDelete([int|null $bodId = null ]) : bool
Parameters
$bodId : int|null = null
Tags
see
Bot::unRegister

Method registers at bot field b_im_bot.METHOD_BOT_DELETE

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
$joinFields : array<string|int, mixed>
Tags
see
Bot::onJoinChat

Method registers at bot field b_im_bot.METHOD_WELCOME_MESSAGE

Return values
bool

onCommandAdd()

Event handler on command add.

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

Incomming message Id.

$messageFields : array<string|int, mixed>

Message fields array.

Tags
see
Command::onCommandAdd

Method registers at bot field b_im_command.METHOD_COMMAND_ADD

Return values
bool

onMessageAdd()

Event handler on message add.

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

Outgoing message Id.

$messageFields : array<string|int, mixed>

Message fields array.

Tags
see
Bot::onMessageAdd

Method registers at bot field b_im_bot.METHOD_MESSAGE_ADD

Return values
bool

register()

Register bot at portal.

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

unRegister()

Unregister bot at portal.

public static unRegister() : bool
Return values
bool

        
On this page

Search results