Views: 2636
Last Modified: 14.06.2022

Sending Open Channel message to selected user

Revision You can get information about the current API version (platform version) as follows: im.revision.get : 2

Attention! To use the IMOPENLINES REST methods you need to have access permissions for imbot (Creating and managing chat bots) as well as access to the imopenlines (Open channels) scope.

Parameters

Parameter Example Req. Description Revision
CODE ab515f5d85a8b844d484f6ea75a2e494 Yes Registered Open Channel code 1
USER_ID 2 Yes Message recipient ID 1
MESSAGE message text Yes Message text 1
ATTACH No Attachment 1
KEYBOARD No Keyboard 1
URL_PREVIEW Y No Convert links to rich links, by default set as 'Y' 1


Method call and response

PHP

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

	'CODE' => 'ab515f5d85a8b844d484f6ea75a2e494',
	'USER_ID' => 2,
	'MESSAGE' => 'message text',
	'ATTACH' => '',
	'KEYBOARD' => '',
	'URL_PREVIEW' => 'Y'

), $_REQUEST["auth"]);

Response example

{
	"result": true
}
Result: true or error.

Restrictions

  • You can send message not more than once for each user during a one week period.

    Note: There are no restrictions for the account with Partner (NFR) license.

  • You can use keyboard only for formatting link button at third-party site.

Response example on error

{
    "error": "CODE_ERROR",
    "error_description": "Open Channel code is incorrect"
}

Key description:

  • error – error code
  • error_description – error brief description

Possible error codes

Code Description
CODE_ERROR Open Channel code is incorrect.
USER_ID_EMPTY User ID is empty.
MESSAGE_EMPTY Message text is empty.
ATTACH_ERROR Attachment object is not validated.
ATTACH_OVERSIZE Maximum permissible attachment size exceeded (30 Kb).
KEYBOARD_ERROR Passed keyboard object is not validated.
KEYBOARD_OVERSIZE Maximum permissible keyboard size exceeded (30 Kb).
USER_MESSAGE_LIMIT Message limit exceeded for specific user.
WRONG_REQUEST Something went wrong.


Related links:





Courses developed by Bitrix24