Views: 12897
Last Modified: 22.08.2022
Attention! You need to have access to the
imopenlines (Open Channels) scope to use the methods IMOPENLINES REST in addition to the
imbot (Creating and managing chatbots) access permissions.
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 code | Error 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.send
Method call:
$result = restCommand('imopenlines.network.message.send', 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 code | Error 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 code | Error 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 code | Error 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 code | Error description |
CHAT_ID_EMPTY |
No chat ID. |
BOT_ID_ERROR |
Incorrect chatbot ID. |
|
Sending chatbot automatic message
REST method:
imopenlines.bot.session.message.send
Revision: 1
Get information on current API revision (Open channel platform version) – imopenlines.revision.get.
Parameters
Parameter |
Example |
Required |
Description |
Revision |
CHAT_ID |
2 |
Yes |
Chat ID received by current operator |
1 |
MESSAGE |
message text |
Yes |
Message text |
1 |
NAME |
WELCOME |
Yes |
Message type: WELCOME - greetings message, DEFAULT - standard message. Empty be default |
1 |
|
Method call and response
PHP
$result = restCommand('imopenlines.bot.session.message.send', Array(
'CHAT_ID' => 2,
'MESSAGE' => 'message text',
'NAME' => 'WELCOME'
), $_REQUEST["auth"]);
Response example
{
"result": true
}
Returns:
true
or error.