Skip to content

新增应用反馈

当应用收到新反馈时,触发该事件

事件

项目
事件类型application.application.feedback.created_v6
支持的应用类型custom,isv
权限要求 订阅该事件所需的权限,开启其中任意一项权限即可订阅application:application.feedback.feedback_info 管理应用反馈数据
字段权限要求> Tip: 该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请 contact:user.email:readonly 获取用户邮箱信息 contact:user.employee_id:readonly 获取用户 user ID contact:user.phone:readonly 获取用户手机号
推送方式Webhook

事件体

名称类型描述
schemastring事件模式
headerevent_header事件头
  └ event_idstring事件 ID
  └ event_typestring事件类型
  └ create_timestring事件创建时间戳(单位:毫秒)
  └ tokenstring事件 Token
  └ app_idstring应用 ID
  └ tenant_keystring租户 Key
event\--
  └ user_iduser_id用户 ID
    └ union_idstring用户的 union id
    └ user_idstring用户的 user id
字段权限要求contact:user.employee_id:readonly 获取用户 user ID
    └ open_idstring用户的 open id
  └ app_idstring被反馈应用 ID
  └ feedback_timestring反馈提交时间,格式为yyyy-mm-dd hh:mm:ss
  └ tenant_namestring反馈用户的租户名
  └ feedback_typeint反馈类型(枚举值,1:故障反馈,2:产品建议)
  └ fault_typeint\[\]故障类型列表:1: 黑屏 2: 白屏 3: 无法打开小程序 4: 卡顿 5: 小程序闪退 6: 页面加载慢 7: 死机 8: 其他异常
  └ fault_timestring故障时间,格式为yyyy-mm-dd hh:mm:ss
  └ sourceint反馈来源:1: 小程序 2:网页应用 3:机器人 4:webSDK
  └ contactstring用户填写的联系方式
字段权限要求(满足任一)contact:user.email:readonly 获取用户邮箱信息 contact:user.phone:readonly 获取用户手机号
  └ descriptionstring反馈详情
  └ imagesstring\[\]反馈图片url列表,url 过期时间三天
  └ feedback_idstring应用反馈 ID,应用反馈记录唯一标识
  └ feedback_pathstring反馈页面路径

事件体示例

json
{
    "schema": "2.0",
    "header": {
        "event_id": "5e3702a84e847582be8db7fb73283c02",
        "event_type": "application.application.feedback.created_v6",
        "create_time": "1608725989000",
        "token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
        "app_id": "cli_9f5343c580712544",
        "tenant_key": "2ca1d211f64f6438"
    },
    "event": {
        "user_id": {
            "union_id": "on_8ed6aa67826108097d9ee143816345",
            "user_id": "e33ggbyz",
            "open_id": "ou_84aad35d084aa403a838cf73ee18467"
        },
        "app_id": "cli_9b445f5258795107",
        "feedback_time": "2022-01-30 11:30:12",
        "tenant_name": "字节跳动",
        "feedback_type": 1,
        "fault_type": [
            1,2,3
        ],
        "fault_time": "2022-01-30 11:30:12",
        "source": 1,
        "contact": "wang@bytedance.com",
        "description": "反馈的详细信息",
        "images": [
            "https://p6-lark-openplatform-image-sign.byteimg.com/*"
        ],
        "feedback_id": "7057888018203574291",
        "feedback_path": "page/index"
    }
}

事件订阅示例代码

事件订阅流程可参考:事件订阅概述,新手入门可参考:教程

订阅方式

长连接方式(推荐):无需发布到公网地址,在本地开发环境中即可接收事件回调,且无需处理加解密逻辑。 发送至开发者服务器:需要提供服务器公网地址。

package main

import (
	"context"
	"fmt"

	larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
	larkws "github.com/larksuite/oapi-sdk-go/v3/ws"
)

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ApplicationFeedbackCreatedV6(func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackCreatedV6) error {
			fmt.Printf("[ OnP2ApplicationFeedbackCreatedV6 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

	// 构建 client Build client
	cli := larkws.NewClient("YOUR_APP_ID", "YOUR_APP_SECRET",
		larkws.WithEventHandler(eventHandler),
		larkws.WithLogLevel(larkcore.LogLevelDebug),
	)

	// 建立长连接 Establish persistent connection
	err := cli.Start(context.Background())

	if err != nil {
		panic(err)
	}
}
# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
import lark_oapi as lark


def do_p2_application_application_feedback_created_v6(data: lark.application.v6.P2ApplicationApplicationFeedbackCreatedV6) -> None:
    print(f'[ do_p2_application_application_feedback_created_v6 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_application_application_feedback_created_v6(do_p2_application_application_feedback_created_v6) \
    .build()


def main():
    # 构建 client Build client
    cli = lark.ws.Client("APP_ID", "APP_SECRET",
                        event_handler=event_handler, log_level=lark.LogLevel.DEBUG)
    # 建立长连接 Establish persistent connection
    cli.start()

if __name__ == "__main__":
    main()
package com.example.sample;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.application.ApplicationService;
import com.lark.oapi.service.application.v6.model.P2ApplicationFeedbackCreatedV6;
import com.lark.oapi.event.EventDispatcher;
import com.lark.oapi.ws.Client;

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
public class Sample {
    // 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("", "")
            .onP2ApplicationFeedbackCreatedV6(new ApplicationService.P2ApplicationFeedbackCreatedV6Handler() {
                @Override
                public void handle(P2ApplicationFeedbackCreatedV6 event) throws Exception {
                    System.out.printf("[ onP2ApplicationFeedbackCreatedV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

    public static void main(String[] args) {
        // 构建 client Build client
        Client client = new Client.Builder("APP_ID", "APP_SECRET")
                .eventHandler(EVENT_HANDLER)
                .build();
        // 建立长连接 Establish persistent connection
        client.start();
    }
}
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import * as Lark from '@larksuiteoapi/node-sdk';
const baseConfig = {
    appId: 'APP_ID',
    appSecret: 'APP_SECRET'
}
// 构建 client Build client
const wsClient = new Lark.WSClient(baseConfig);
// 建立长连接 Establish persistent connection
wsClient.start({
    // 注册事件 Register event
    eventDispatcher: new Lark.EventDispatcher({}).register({
        'application.application.feedback.created_v6': async (data) => {
            console.log(data);
        }
    })
});
package main

import (
	"context"
	"fmt"
	"net/http"

	larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
	"github.com/larksuite/oapi-sdk-go/v3/core/httpserverext"
	larkevent "github.com/larksuite/oapi-sdk-go/v3/event"
	"github.com/larksuite/oapi-sdk-go/v3/event/dispatcher"
	"github.com/larksuite/oapi-sdk-go/v3/service/application/v6"
)

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/golang-sdk-guide/preparations
func main() {
	// 注册事件 Register event
	eventHandler := dispatcher.NewEventDispatcher("", "").
		OnP2ApplicationFeedbackCreatedV6(func(ctx context.Context, event *larkapplication.P2ApplicationFeedbackCreatedV6) error {
			fmt.Printf("[ OnP2ApplicationFeedbackCreatedV6 access ], data: %s\n", larkcore.Prettify(event))
			return nil
		})

	// 创建路由处理器 Create route handler
	http.HandleFunc("/webhook/event", httpserverext.NewEventHandlerFunc(handler, larkevent.WithLogLevel(larkcore.LogLevelDebug)))

	err := http.ListenAndServe(":7777", nil)

	if err != nil {
		panic(err)
	}
}
# SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/python--sdk/preparations-before-development
from flask import Flask
from lark_oapi.adapter.flask import *
import lark_oapi as lark

app = Flask(__name__)


def do_p2_application_application_feedback_created_v6(data: lark.application.v6.P2ApplicationApplicationFeedbackCreatedV6) -> None:
    print(f'[ do_p2_application_application_feedback_created_v6 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_application_application_feedback_created_v6(do_p2_application_application_feedback_created_v6) \
    .build()


# 创建路由处理器 Create route handler
@app.route("/webhook/event", methods=["POST"])
def event():
    resp = event_handler.do(parse_req())
    return parse_resp(resp)

if __name__ == "__main__":
    app.run(port=7777)
package com.lark.oapi.sample.event;

import com.lark.oapi.core.utils.Jsons;
import com.lark.oapi.service.application.ApplicationService;
import com.lark.oapi.service.application.v6.model.P2ApplicationFeedbackCreatedV6;
import com.lark.oapi.sdk.servlet.ext.ServletAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/java-sdk-guide/preparations
@RestController
public class EventController {

    // 注册事件 Register event
    private static final EventDispatcher EVENT_HANDLER = EventDispatcher.newBuilder("verificationToken", "encryptKey")
            .onP2ApplicationFeedbackCreatedV6(new ApplicationService.P2ApplicationFeedbackCreatedV6Handler() {
                @Override
                public void handle(P2ApplicationFeedbackCreatedV6 event) throws Exception {
                    System.out.printf("[ onP2ApplicationFeedbackCreatedV6 access ], data: %s\n", Jsons.DEFAULT.toJson(event.getEvent()));
                }
            })
            .build();

    // 注入 ServletAdapter 实例 Inject ServletAdapter instance
    @Autowired
    private ServletAdapter servletAdapter;

    // 创建路由处理器 Create route handler
    @RequestMapping("/webhook/event")
    public void event(HttpServletRequest request, HttpServletResponse response)
            throws Throwable {
        // 回调扩展包提供的事件回调处理器 Callback handler provided by the extension package
        servletAdapter.handleEvent(request, response, EVENT_DISPATCHER);
    }
}
// SDK 使用说明 SDK user guide:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/server-side-sdk/nodejs-sdk/preparation-before-development
import http from 'http';
import * as lark from '@larksuiteoapi/node-sdk';

// 注册事件 Register event
const eventDispatcher = new lark.EventDispatcher({
    encryptKey: '',
    verificationToken: '',
}).register({
    'application.application.feedback.created_v6': async (data) => {
        console.log(data);
        return 'success';
    },
});

const server = http.createServer();
// 创建路由处理器 Create route handler
server.on('request', lark.adaptDefault('/webhook/event', eventDispatcher));
server.listen(3000);

内容来源:飞书开放平台 · 自动爬取整理