Views: 7317
Last Modified: 28.11.2017

Treat the ATTACH object like it's a LEGO toy. Construct it according to your vision and requirements using available block types. The order in which you specify blocks is relevant.


Example «A Bug Tracker»

restCommand('imbot.message.add', Array(
   "DIALOG_ID" => $_REQUEST['data']['PARAMS']['DIALOG_ID'],
   "MESSAGE" => "You have a new notification",
   "ATTACH" => Array(
      Array("USER" => Array(
         "NAME" => "Mantis Notifications",
         "AVATAR" => "http://shelenkov.com/bitrix/images/mantis2.jpg",
         "LINK" => "http://shelenkov.com/",
      )),
      Array("LINK" => Array(
         "NAME" => "Open Mantis",
         "LINK" => "http://shelenkov.com/",
      )),
      Array("DELIMITER" => Array(
         'SIZE' => 200,
         'COLOR' => "#c6c6c6"
      )),
      Array("GRID" => Array(
         Array(
            "NAME" => "Project",
            "VALUE" => "BUGS",
            "DISPLAY" => "LINE",
            "WIDTH" => 100
         ),
         Array(
            "NAME" => "Category",
            "VALUE" => "im",
            "DISPLAY" => "LINE",
            "WIDTH" => 100
         ),
         Array(
            "NAME" => "Summary",
            "VALUE" => "Structured entity enclosures are required in IM messages and notifications.",
            "DISPLAY" => "BLOCK"
         ),
      )),
      Array("DELIMITER" => Array(
         'SIZE' => 200,
         'COLOR' => "#c6c6c6"
      )),
      Array("GRID" => Array(
         Array(
            "NAME" => "New ticket",
            "VALUE" => "",
            "DISPLAY" => "ROW",
            "WIDTH" => 100
         ),
         Array(
            "NAME" => "Assigned to",
            "VALUE" => "Evgeniy Shelenkov",
            "DISPLAY" => "ROW",
            "WIDTH" => 100
         ),
         Array(
            "NAME" => "Deadline",
            "VALUE" => "04.11.2015 17:50:43",
            "DISPLAY" => "ROW",
            "WIDTH" => 100
         ),
      )),
   )
), $_REQUEST["auth"]);


Example: Notification

restCommand('imbot.message.add', Array(
   "DIALOG_ID" => $_REQUEST['data']['PARAMS']['DIALOG_ID'],
   "MESSAGE" => "You have new notification",
   "ATTACH" => Array(
      Array("MESSAGE" => "Hey guys, update [b]im 16.0.0[/b] has been tested and is now ready for release.[BR] Add tags as required.[BR] No new commits are accepted."),
      Array("IMAGE" => Array(
         "LINK" => "http://shelenkov.com/bitrix/images/win.jpg",
      )),
   )
), $_REQUEST["auth"]);




Courses developed by Bitrix24