Views: 2722 (Data available since 06.02.2017)

Attention! To use methods IMOPENLINES REST, sufficient rights are required to imbot (Create and manage chatbots) available access to scope imopenlines (Open Channels).


Connect Open Channel via code

REST method: imopenlines.network.join

Method call:
$result = restCommand('imopenlines.network.join', Array(

    'CODE' => 'ab515f5d85a8b844d484f6ea75a2e494' // code for search from connector page

), $_REQUEST["auth"]);
Return: true or error code.

Possible errors:

Error codeError description
IMBOT_ERROR Bot management module is not installed.
NOT_FOUND Open Channel not found.
INACTIVE Open Channel is unavailable at the moment.

Sent message from Open Channel to selected user

REST method: imopenlines.network.message.add

Method call:
$result = restCommand('imopenlines.network.message.add', Array(

	'CODE' => 'ab515f5d85a8b844d484f6ea75a2e494', // code of registered open channel
	'USER_ID' => 2, // message recipient user code
	'MESSAGE' => 'message text' // Message text
	'ATTACH' => '' // Attachment, optional field
	'KEYBOARD' => '' // Keyboard, optional field
	'URL_PREVIEW' => 'Y' // Concert link to rich-link, optional field, by default 'Y'

), $_REQUEST["auth"]);
Return: true or error code.

Limitations:
  • You can send a message not more than once for each user during a week.
  • You can use keyboard only to configure the button-link to external site.

Related links:

Using Keyboards
Attachments
Formatting

Possible errors:

Error codeError description
CODE_ERROR Incorrect code for Open Channel.
USER_ID_EMPTY No ID for recipient user.
MESSAGE_EMPTY No message text.
ATTACH_ERROR Attachment object was not validated.
ATTACH_OVERSIZE Maximum permissible attachment size was exceeded (30 Kb).
KEYBOARD_ERROR Keyboard object was not validated.
KEYBOARD_OVERSIZE Maximum permissible keyboard size was exceeded (30 Kb).
USER_MESSAGE_LIMIT Message limit for specific user was exceeded.
WRONG_REQUEST Something went wrong.


Switch conversation to a free operator

REST method: imopenlines.bot.session.operator

Method call:
$result = restCommand('imopenlines.bot.session.operator', Array(

    'CHAT_ID' => 12 // Chat ID

), $_REQUEST["auth"]);
Return: true or Error code.

Possible errors:

Error codeError description
CHAT_ID_EMPTY No chat ID.
WRONG_CHAT Specified chat is not under bot control.
BOT_ID_ERROR Incorrect chatbot ID.


Switch conversation to a specific operator

REST method: imopenlines.bot.session.transfer

Method call:
$result = restCommand('imopenlines.bot.session.transfer', Array(

    'CHAT_ID' => 12 // Chat ID
    'USER_ID' => 12 // User ID, to which forwarding is performed
    'LEAVE' => 'N' // Y/N. If 'Nā€™ is specified ā€“ chatbot will not leave this chat after forwarding and will be available until user is confirmed	

), $_REQUEST["auth"]);

Note: Instead of USER_ID, QUEUE_ID can be specified to switch to another open channel.

Return: true or Error code.

Possible errors:

Error codeError description
CHAT_ID_EMPTY No chat ID.
USER_ID_EMPTY No user ID, to which conversation must be forwarded.
WRONG_CHAT Incorrect user ID is specified, or this user is chatbot or extranet user.
BOT_ID_ERROR Incorrect chatbot ID.


Current session finish

REST method: imopenlines.bot.session.finish

Method call:
$result = restCommand('imopenlines.bot.session.finish', Array(

    'CHAT_ID' => 12 // Chat ID	

), $_REQUEST["auth"]);
Return: true or Error code.

Possible errors:

Error codeError description
CHAT_ID_EMPTY No chat ID.
BOT_ID_ERROR Incorrect chatbot ID.


Note: Based on Open Channel REST API you can create technical support channel for your clients.





Courses developed by «Bitrix», Inc.