当前位置:   article > 正文

feishu-飞书交互机器人开发_飞书机器人开发

飞书机器人开发

title: feishu-飞书交互机器人开发
categories: Feishu
tags: [飞书, api, 机器人]
date: 2021-10-16 16:06:26
comments: false
mathjax: true
toc: true

feishu-飞书交互机器人开发


前篇

  • 官方
    • 事件订阅概述 - https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM
    • 参考代码 - https://open.feishu.cn/document/home/develop-a-bot-in-5-minutes/coding
    • 订阅事件列表 - https://open.feishu.cn/document/ukTMukTMukTM/uYDNxYjL2QTM24iN0EjN/event-list

流程

  1. 创建 机器人应用

  2. 启用机器人

  3. 获取相关参数:

    1. appid, app secret

    2. Verification Token , Encrypt Key (非必须)

  4. 配置 请求网址

    注意, 配置请求网址时, 需要启动好服务, 因为点击 保存 时, 飞书会去检测服务是否合法


接收数据

单聊
{
    "schema": "2.0",
    "header": {
        "event_id": "8b2c88ad4704eb90eca6d1113a4adbcd",
        "token": "duxbbHtnGLampGhotmBg9ULesmHBDfBZ",
        "create_time": "1634371309743",
        "event_type": "im.message.receive_v1",
        "tenant_key": "13cbf99e6a0f175e",
        "app_id": "cli_a1d96e502478500c"
    },
    "event": {
        "message": {
            "chat_id": "oc_dc97f47a1cb562ab32e6504be5745adc",
            "chat_type": "p2p",
            "content": "{\"text\":\"11\"}",
            "create_time": "1634371309564",
            "message_id": "om_b6bec1170d06865491f374f594ce6be2",
            "message_type": "text"
        },
        "sender": {
            "sender_id": {
                "open_id": "ou_acc48efbf7a13be212bf9e5b8bbd5a11",
                "union_id": "on_4c95af379a29a957a02a66349eb3c6d4",
                "user_id": "gag2a216"
            },
            "sender_type": "user",
            "tenant_key": "13cbf99e6a0f175e"
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

群里 @ 机器人
{
    "schema": "2.0",
    "header": {
        "event_id": "aa25beadec35205718786f602bcd2661",
        "token": "duxbbHtnGLampGhotmBg9ULesmHBDfBZ",
        "create_time": "1634370421496",
        "event_type": "im.message.receive_v1",
        "tenant_key": "13cbf99e6a0f175e",
        "app_id": "cli_a1d96e502478500c"
    },
    "event": {
        "message": {
            "chat_id": "oc_15ed0b49b1de8dac5542363ac4dec90d",
            "chat_type": "group",
            "content": "{\"text\":\"@_user_1 中国智造\"}",
            "create_time": "1634370421100",
            "mentions": [
                {
                    "id": {
                        "open_id": "ou_b32abc1a55f7bc597d8e5d25ea337eaf",
                        "union_id": "on_609321e054cf257f09540a10df6c15c2",
                        "user_id": ""
                    },
                    "key": "@_user_1",
                    "name": "bot-msg",
                    "tenant_key": "13cbf99e6a0f175e"
                }
            ],
            "message_id": "om_689890eb294f514e4acc84a83c955fc9",
            "message_type": "text"
        },
        "sender": {
            "sender_id": {
                "open_id": "ou_acc48efbf7a13be212bf9e5b8bbd5a11",
                "union_id": "on_4c95af379a29a957a02a66349eb3c6d4",
                "user_id": "gag2a216"
            },
            "sender_type": "user",
            "tenant_key": "13cbf99e6a0f175e"
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

文件消息
{
    "event": {
        "message": {
            "chat_id": "oc_dc97f47a1cb562ab32e6504be5745adc",
            "chat_type": "p2p",
            "content": "{\"file_key\":\"file_v2_b611a01a-e2ca-4830-ac7e-017c9333212g\",\"file_name\":\"VIP玩家.xlsx\"}",
            "create_time": "1635741623964",
            "message_id": "om_d7471e5c1a60edc15ff60c3696fee787",
            "message_type": "file"
        },
        "sender": {
            "sender_id": {
                "open_id": "ou_acc48efbf7a13be212bf9e5b8bbd5a11",
                "union_id": "on_4c95af379a29a957a02a66349eb3c6d4",
                "user_id": "gag2a216"
            },
            "sender_type": "user",
            "tenant_key": "13cbf99e6a0f175e"
        }
    },
    "header": {
        "app_id": "cli_a1d96e502478500c",
        "create_time": "1635741624375",
        "event_id": "35b237099dcbf86ee78ccd58cea31c92",
        "event_type": "im.message.receive_v1",
        "tenant_key": "13cbf99e6a0f175e",
        "token": "duxbbHtnGLampGhotmBg9ULesmHBDfBZ"
    },
    "schema": "2.0"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/572918
推荐阅读
相关标签
  

闽ICP备14008679号