umbot - v2.0.8
    Preparing search index...

    Class SmartAppButton

    SmartAppButton Класс для работы с кнопками в Сбер SmartApp

    Предоставляет функциональность для создания и отображения кнопок в Сбер SmartApp:

    • Поддержка различных типов кнопок (текст, deep link, server action)
    • Автоматическое ограничение длины текста кнопок (до 64 символов)
    • Поддержка payload для передачи данных
    • Возможность использования кнопок в карточках
    const smartAppButton = new SmartAppButton();

    // Создание текстовой кнопки
    smartAppButton.buttons = [
    new Button('Ответить', null, {
    payload: 'custom_payload'
    })
    ];
    const textResult = smartAppButton.getButtons();
    // textResult: [{
    // title: 'Ответить',
    // action: {
    // type: 'server_action',
    // server_action: 'custom_payload'
    // }
    // }]

    // Создание кнопки-ссылки
    smartAppButton.buttons = [
    new Button('Открыть сайт', 'https://example.com', { action: 'link' })
    ];
    const linkResult = smartAppButton.getButtons();
    // linkResult: [{
    // title: 'Открыть сайт',
    // action: {
    // type: 'text',
    // text: 'Открыть сайт'
    // }
    // }]

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    isCard: boolean

    Флаг использования кнопок в карточке

    • true: кнопки для карточки (один из типов: text, deep_link)
    • false: кнопки-подсказки (массив кнопок с действиями)
    false
    
    const smartAppButton = new SmartAppButton();

    // Создание кнопки для карточки
    smartAppButton.isCard = true;
    smartAppButton.buttons = [
    new Button('Открыть сайт', 'https://example.com')
    ];
    const cardResult = smartAppButton.getButtons();
    // cardResult: {
    // type: 'deep_link',
    // deep_link: 'https://example.com'
    // }

    // Создание текстовой кнопки для карточки
    smartAppButton.isCard = true;
    smartAppButton.buttons = [
    new Button('Подтвердить')
    ];
    const textCardResult = smartAppButton.getButtons();
    // textCardResult: {
    // type: 'text',
    // text: 'Подтвердить'
    // }
    buttons: Button[]

    Массив кнопок для отображения

    const buttonHandler = new AlisaButton();
    buttonHandler.buttons = [
    new Button('Открыть сайт', 'https://example.com'),
    new Button('Позвонить', 'tel:+79001234567')
    ];

    Methods

    • Получение кнопок в формате Сбер SmartApp

      Returns ISberSmartAppCardAction | ISberSmartAppSuggestionButton[]

      • Объект с кнопками:
      • Для обычных кнопок: массив кнопок-подсказок
      • Для карточки: одна кнопка (text или deep_link)

      Поддерживаемые типы кнопок:

      • text: Текстовая кнопка
      • deep_link: Кнопка-ссылка
      • server_action: Кнопка с серверным действием

      Правила формирования кнопок:

      • Текст кнопки автоматически обрезается до 64 символов
      • Для карточки поддерживается только одна кнопка
      • При наличии payload создается кнопка типа server_action
      • При наличии URL создается кнопка типа deep_link
      const smartAppButton = new SmartAppButton();

      // Создание кнопок-подсказок
      smartAppButton.buttons = [
      new Button('Подтвердить', null, { payload: 'confirm' }),
      new Button('Отменить', null, { payload: 'cancel' })
      ];
      const suggestionsResult = smartAppButton.getButtons();
      // suggestionsResult: [
      // {
      // title: 'Подтвердить',
      // action: {
      // type: 'server_action',
      // server_action: 'confirm'
      // }
      // },
      // {
      // title: 'Отменить',
      // action: {
      // type: 'server_action',
      // server_action: 'cancel'
      // }
      // }
      // ]

      // Создание кнопки для карточки с deep link
      smartAppButton.isCard = true;
      smartAppButton.buttons = [
      new Button('Открыть приложение', 'sberapp://example.com')
      ];
      const deepLinkResult = smartAppButton.getButtons();
      // deepLinkResult: {
      // type: 'deep_link',
      // deep_link: 'sberapp://example.com'
      // }