# Starting a meeting

Occurs at the beginning of the meeting [This event occurs in meetings booked by Open API only]{Usage Examples}(url=/api/tools/api_explore/api_explore_config?project=vc&version=v1&resource=meeting&event=meeting_started)

## Event

Facts | &nbsp;
---|---
Event type | vc.meeting.meeting_started_v1
Supported app types | Custom App、Store App
Required scopes<br>**To subscribe to this event, enable any of the listed scopes.** | Obtain meeting information(vc:meeting:readonly)
Required field scopes | **Notice**：The response body of the API contains the following sensitive fields, and they will be returned only after corresponding scopes are added. If you do not need the fields, it is not recommended that you request the scopes.<br>Obtain user ID(contact:user.employee_id:readonly)
Push Mode | [Webhook](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)

### Event body

Parameter | Type | Description
---|---|---
schema | string | Event schema
header | event_header | Event header
event_id | string | Event ID
event_type | string | Event type
create_time | string | Event creation timestamp(in ms)
token | string | Event token
app_id | string | App ID
tenant_key | string | Tenant key
event | \- | \-
meeting | meeting_event_meeting | Meeting data
id | string | Meeting ID (Unique identifier of video conference, generated after the conference is started)
topic | string | Meeting topic
meeting_no | string | 9-digit meeting number (Feishu users can join the meeting by entering this number)
meeting_source | int | Meeting Creation Source<br>**Optional values are**:<br>- 1：Schedule Meeting<br>- 2：Instant meeting<br>- 3：Interview meeting<br>- 4：Open platform meeting<br>- 100：Other meeting types
start_time | string | Meeting start time (Unix time in sec)
end_time | string | Meeting end time (Unix time in sec)
host_user | meeting_event_user | Meeting host
id | user_id | User ID
union_id | string | User's union_id
user_id | string | user's user id<br>**Required field scopes**:<br>Obtain user ID(contact:user.employee_id:readonly)
open_id | string | User's open_id
user_role | int | User's role in a meeting<br>**Optional values are**:<br>- 1：Participant<br>- 2：Host<br>- 3：Co-host
user_type | int | User type<br>**Optional values are**:<br>- 1：Lark user<br>- 2：Rooms user<br>- 3：Docs user<br>- 4：neo Feishu Meetings user<br>- 5：neo Feishu Meetings guest<br>- 6：PSTN user<br>- 7：SIP user
owner | meeting_event_user | Meeting owner
id | user_id | User ID
union_id | string | User's union_id
user_id | string | user's user id<br>**Required field scopes**:<br>Obtain user ID(contact:user.employee_id:readonly)
open_id | string | User's open_id
user_role | int | User's role in a meeting<br>**Optional values are**:<br>- 1：Participant<br>- 2：Host<br>- 3：Co-host
user_type | int | User type<br>**Optional values are**:<br>- 1：Lark user<br>- 2：Rooms user<br>- 3：Docs user<br>- 4：neo Feishu Meetings user<br>- 5：neo Feishu Meetings guest<br>- 6：PSTN user<br>- 7：SIP user
calendar_event_id | string | Unique identifier of the calendar event
operator | meeting_event_user | Event operator
id | user_id | User ID
union_id | string | User's union_id
user_id | string | user's user id<br>**Required field scopes**:<br>Obtain user ID(contact:user.employee_id:readonly)
open_id | string | User's open_id
user_role | int | User's role in a meeting<br>**Optional values are**:<br>- 1：Participant<br>- 2：Host<br>- 3：Co-host
user_type | int | User type<br>**Optional values are**:<br>- 1：Lark user<br>- 2：Rooms user<br>- 3：Docs user<br>- 4：neo Feishu Meetings user<br>- 5：neo Feishu Meetings guest<br>- 6：PSTN user<br>- 7：SIP user

### Event body example
```json
{
    "schema": "2.0",
    "header": {
        "event_id": "5e3702a84e847582be8db7fb73283c02",
        "event_type": "vc.meeting.meeting_started_v1",
        "create_time": "1608725989000",
        "token": "rvaYgkND1GOiu5MM0E1rncYC6PLtF7JV",
        "app_id": "cli_9f5343c580712544",
        "tenant_key": "2ca1d211f64f6438"
    },
    "event": {
        "meeting": {
            "id": "6911188411934433028",
            "topic": "my meeting",
            "meeting_no": "235812466",
            "meeting_source": 1,
            "start_time": "1608883322",
            "end_time": "1608883899",
            "host_user": {
                "id": {
                    "union_id": "on_8ed6aa67826108097d9ee143816345",
                    "user_id": "e33ggbyz",
                    "open_id": "ou_84aad35d084aa403a838cf73ee18467"
                },
                "user_role": 1,
                "user_type": 1
            },
            "owner": {
                "id": {
                    "union_id": "on_8ed6aa67826108097d9ee143816345",
                    "user_id": "e33ggbyz",
                    "open_id": "ou_84aad35d084aa403a838cf73ee18467"
                },
                "user_role": 1,
                "user_type": 1
            },
            "calendar_event_id": "efa67a98-06a8-4df5-8559-746c8f4477ef_0"
        },
        "operator": {
            "id": {
                "union_id": "on_8ed6aa67826108097d9ee143816345",
                "user_id": "e33ggbyz",
                "open_id": "ou_84aad35d084aa403a838cf73ee18467"
            },
            "user_role": 1,
            "user_type": 1
        }
    }
}
```

### Sample code for event subscriptions

For event subscription process, refer to:[Event Subscription overview](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)，Guide for beginners:[Tutorial](https://open.feishu.cn/document/uAjLw4CM/uMzNwEjLzcDMx4yM3ATM/develop-an-echo-bot/introduction)

**

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/vc/v1"
	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("", "").
		OnP2MeetingStartedV1(func(ctx context.Context, event *larkvc.P2MeetingStartedV1) error {
			fmt.Printf("[ OnP2MeetingStartedV1 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_vc_meeting_meeting_started_v1(data: lark.vc.v1.P2VcMeetingMeetingStartedV1) -> None:
    print(f'[ do_p2_vc_meeting_meeting_started_v1 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_vc_meeting_meeting_started_v1(do_p2_vc_meeting_meeting_started_v1) \
    .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.vc.VcService;
import com.lark.oapi.service.vc.v1.model.P2MeetingStartedV1;
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("", "")
            .onP2MeetingStartedV1(new VcService.P2MeetingStartedV1Handler() {
                @Override
                public void handle(P2MeetingStartedV1 event) throws Exception {
                    System.out.printf("[ onP2MeetingStartedV1 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({
        'vc.meeting.meeting_started_v1': 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/vc/v1"
)

// 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("", "").
		OnP2MeetingStartedV1(func(ctx context.Context, event *larkvc.P2MeetingStartedV1) error {
			fmt.Printf("[ OnP2MeetingStartedV1 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_vc_meeting_meeting_started_v1(data: lark.vc.v1.P2VcMeetingMeetingStartedV1) -> None:
    print(f'[ do_p2_vc_meeting_meeting_started_v1 access ], data: {lark.JSON.marshal(data, indent=4)}')

# 注册事件 Register event
event_handler = lark.EventDispatcherHandler.builder("", "") \
    .register_p2_vc_meeting_meeting_started_v1(do_p2_vc_meeting_meeting_started_v1) \
    .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.vc.VcService;
import com.lark.oapi.service.vc.v1.model.P2MeetingStartedV1;
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")
            .onP2MeetingStartedV1(new VcService.P2MeetingStartedV1Handler() {
                @Override
                public void handle(P2MeetingStartedV1 event) throws Exception {
                    System.out.printf("[ onP2MeetingStartedV1 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({
    'vc.meeting.meeting_started_v1': 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);

