【问题标题】:Botkit - Slack interactive messagesBotkit - Slack 交互式消息
【发布时间】:2018-02-01 13:16:02
【问题描述】:

我正在尝试从所有操作中获取所有值。目前我有两个选择动作(选择一个游戏和选择一天)。在 interactive_messages_callback 中,我只获取当前修改的选择的选定值。

有没有办法从 currentValues: [ os_type_selection: 'osx', day_selection: '2' ] 等所有操作中获取一组值?

bot.reply(message, {
  attachments: [
    {
      title: 'Question 1',
      callback_id: 'question_1',
      attachment_type: 'default',
      actions: [
        {
          name: 'os_type_selection',
          text: 'Pick a game...',
          type: 'select',
          options: [
            {
              text: 'Mac OS X',
              value: 'osx',
            },
            {
              text: 'Windows',
              value: 'windows',
            }
          ]
        }
      ],
    },
    {
      title: 'Question 2',
      callback_id: 'question_2',
      attachment_type: 'default',
      actions: [
        {
          name: 'day_selection',
          text: 'Pick a day...',
          type: 'select',
          options: [
            {
              text: 'Monday',
              value: '1',
            },
            {
              text: 'Tuesday',
              value: '2',
            },
          ]
        },
      ],
    },
  ],
});

// interactive_messages_callback

{ type: 'interactive_message_callback',
  actions:
   [ { name: 'day_selection',
       type: 'select',
       selected_options: [Object] } ],
  callback_id: 'question_2',
  team: { id: 'T02L9R6LX', domain: 'hellephant' },
  channel: 'D9066R5NC',
  user: 'U4C2DDM9T',
  action_ts: '1517489936.972094',
  message_ts: '1517489928.000257',
  attachment_id: '2',
  token: 'f5LpbwCQ2D97BhNOPgn1Gotb',
  is_app_unfurl: false,
  original_message:
   { type: 'message',
     user: 'U90RBPAE6',
     text: '...',
     bot_id: 'B90UUGKSR',
     attachments: [ [Object], [Object] ],
     ts: '1517489928.000257' },
  response_url: 'https://hooks.slack.com/actions/T02L9R6LX/309104841078/xsmwspjpdhV1oSW06PQkQZp5',
  trigger_id: '308368498005.2689856711.9425688de7f023516061a4e4b2701322',
  raw_message:
   { type: 'interactive_message',
     actions: [ [Object] ],
     callback_id: 'question_2',
     team: { id: 'T02L9R6LX', domain: 'hellephant' },
     channel: { id: 'D9066R5NC', name: 'directmessage' },
     user: { id: 'U4C2DDM9T', name: 'davidnovak' },
     action_ts: '1517489936.972094',
     message_ts: '1517489928.000257',
     attachment_id: '2',
     token: 'f5LpbwCQ2D97BhNOPgn1Gotb',
     is_app_unfurl: false,
     original_message:
      { type: 'message',
        user: 'U90RBPAE6',
        text: '...',
        bot_id: 'B90UUGKSR',
        attachments: [Object],
        ts: '1517489928.000257' },
     response_url: 'https://hooks.slack.com/actions/T02L9R6LX/309104841078/xsmwspjpdhV1oSW06PQkQZp5',
     trigger_id: '308368498005.2689856711.9425688de7f023516061a4e4b2701322' },
  _pipeline: { stage: 'receive' },
  text: '2' }

【问题讨论】:

    标签: slack slack-api botkit


    【解决方案1】:

    没有。在 Slack 中的同一条消息上不能有多个 interactive menus。它在技术上是可行的,但是一旦用户选择了一个菜单,它就会始终触发该菜单,从而使用户无法同时从多个菜单中进行选择。

    如果您想使用多个菜单,您需要将它们分散到单独的消息中,让用户一个接一个地选择。

    或查看dialog 功能,它允许您同时使用多个菜单。

    【讨论】:

    • 那很好,但是我需要将单个“回复值”存储在某处,但我无法在任何地方获取 convo 实例,因为我想使用 convo.vars..
    • 我在回答中添加了对对话框功能的引用
    猜你喜欢
    • 2019-05-08
    • 1970-01-01
    • 2016-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多