dongpang4470 2017-11-05 17:18
浏览 17
已采纳

应用程序名称未在传出的webhook请求中显示

when ever I try to get the username from slack outgoing hook its showing default username as slackbot.it doesn't show the username of the actual person in this case Nawaf. as u can see it should save the name "Nawaf" or "test" but it's saving "slackbot" what am I doing wrong?

IMAGE 1

IMAGE 2

IMAGE 3

slack outgoing webhook documentation https://api.slack.com/custom-integrations/outgoing-webhooks

  • 写回答

1条回答 默认 最新

  • drz49609 2017-11-06 12:20
    关注

    The reason you don't get the username of the app message in your outgoing webhook request is most likely that this is not supported. Outgoing webhooks is a legacy feature of Slack and replaced by the Events API, which provide a similar functionality, but is way more powerful.

    I tested it to verify your requirement and can confirm that you get the name of the app sending a message with the Events API from message events.

    Here is an example of the message event you receive from a message posted by incoming webhooks (as PHP array):

    array (
      'token' => 'XXX',
      'team_id' => 'T12345678',
      'api_app_id' => 'A12345678',
      'event' => 
      array (
        'text' => 'This is a line of text.
    And this is another one.',
        'username' => 'magic-webhook',
        'bot_id' => 'B12345678',
        'type' => 'message',
        'subtype' => 'bot_message',
        'ts' => '1509969916.000102',
        'channel' => 'G12345678',
        'event_ts' => '1509969916.000102',
      ),
      'type' => 'event_callback',
      'event_id' => 'Ev12345678',
      'event_time' => 1509969916,
      'authed_users' => 
      array (
        0 => 'U12345678',
      ),
    )
    

    For messages posted by Slack apps you won't get the username in the message event directly, but you can then call the API method bots.info with bot_id to get the app name.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据