Skip to content

Commit 3a1550d

Browse files
committed
feat: initial connectors api
1 parent 3db0798 commit 3a1550d

5 files changed

Lines changed: 310 additions & 0 deletions

File tree

magefile.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func Proto() error {
5959
"livekit_rtc.proto",
6060
"livekit_webhook.proto",
6161
"livekit_metrics.proto",
62+
"livekit_connectors.proto",
6263
}
6364
grpcProtoFiles := []string{
6465
"infra/link.proto",
@@ -78,6 +79,11 @@ func Proto() error {
7879
"rpc/whip_signal.proto",
7980
"rpc/sip.proto",
8081
}
82+
connectorProtoFiles := []string{
83+
"connectors/whatsapp_api.proto",
84+
"connectors/whatsapp_common.proto",
85+
"connectors/whatsapp_webhook.proto",
86+
}
8187

8288
fmt.Println("generating protobuf")
8389
target := "livekit"
@@ -193,6 +199,19 @@ func Proto() error {
193199
return err
194200
}
195201

202+
fmt.Println("generating connector protobuf")
203+
args = append([]string{
204+
"--go_out", ".",
205+
"--go_opt=paths=source_relative",
206+
"--plugin=go=" + protocGoPath,
207+
"-I=./protobufs",
208+
}, connectorProtoFiles...)
209+
cmd = exec.Command(protoc, args...)
210+
connectStd(cmd)
211+
if err := cmd.Run(); err != nil {
212+
return err
213+
}
214+
196215
return nil
197216
}
198217

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2025 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package livekit.connectors;
18+
option go_package = "github.com/livekit/protocol/connectors";
19+
option csharp_namespace = "LiveKit.Proto.Connectors";
20+
option ruby_package = "LiveKit::Proto::Connectors";
21+
22+
import "connectors/whatsapp_common.proto";
23+
24+
message WhatsAppCallRequest {
25+
string messaging_product = 1; // always "whatsapp"
26+
optional string to = 2;
27+
optional string call_id = 4;
28+
WhatsAppCallAction action = 5; // action to perform
29+
optional WhatsAppSession session = 6;
30+
optional string biz_opaque_callback_data = 7;
31+
}
32+
33+
enum WhatsAppCallAction {
34+
WHATSAPP_CALL_ACTION_CONNECT = 0;
35+
WHATSAPP_CALL_ACTION_PRE_ACCEPT = 1;
36+
WHATSAPP_CALL_ACTION_ACCEPT = 2;
37+
WHATSAPP_CALL_ACTION_REJECT = 3;
38+
WHATSAPP_CALL_ACTION_TERMINATE = 4;
39+
}
40+
41+
message WhatsAppCallResponse {
42+
optional bool success = 1;
43+
optional string messaging_product = 2;
44+
optional WhatsAppApiError error = 3;
45+
repeated WhatsAppCall calls = 4;
46+
}
47+
48+
message WhatsAppApiError {
49+
uint32 code = 1;
50+
string message = 2;
51+
string type = 3;
52+
optional string fbtrace_id = 4;
53+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2025 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package livekit.connectors;
18+
option go_package = "github.com/livekit/protocol/connectors";
19+
option csharp_namespace = "LiveKit.Proto.Connectors";
20+
option ruby_package = "LiveKit::Proto::Connectors";
21+
22+
import "google/protobuf/timestamp.proto";
23+
import "google/protobuf/duration.proto";
24+
25+
message WhatsAppSession {
26+
WhatsAppSdpType sdp_type = 1;
27+
string sdp = 2;
28+
}
29+
30+
enum WhatsAppSdpType {
31+
WHATSAPP_SDP_TYPE_OFFER = 0;
32+
WHATSAPP_SDP_TYPE_ANSWER = 1;
33+
}
34+
35+
message WhatsAppCall {
36+
string id = 1;
37+
optional string to = 2;
38+
optional string from = 3;
39+
optional WhatsAppCallEvent event = 4;
40+
optional google.protobuf.Timestamp timestamp = 5;
41+
optional WhatsAppCallDirection direction = 6;
42+
optional WhatsAppSession session = 7;
43+
optional string biz_opaque_callback_data = 8;
44+
optional WhatsAppCallStatus status = 9;
45+
optional google.protobuf.Timestamp start_time = 10;
46+
optional google.protobuf.Timestamp end_time = 11;
47+
optional google.protobuf.Duration duration = 12;
48+
}
49+
50+
enum WhatsAppCallEvent {
51+
WHATSAPP_CALL_EVENT_CONNECT = 0;
52+
WHATSAPP_CALL_EVENT_TERMINATE = 1;
53+
}
54+
55+
enum WhatsAppCallDirection {
56+
WHATSAPP_CALL_DIRECTION_USER_INITIATED = 0;
57+
WHATSAPP_CALL_DIRECTION_BUSINESS_INITIATED = 1;
58+
}
59+
60+
enum WhatsAppCallStatus {
61+
WHATSAPP_CALL_STATUS_FAILED = 0;
62+
WHATSAPP_CALL_STATUS_COMPLETED = 1;
63+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright 2025 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package livekit.connectors;
18+
option go_package = "github.com/livekit/protocol/connectors";
19+
option csharp_namespace = "LiveKit.Proto.Connectors";
20+
option ruby_package = "LiveKit::Proto::Connectors";
21+
22+
import "google/protobuf/timestamp.proto";
23+
import "connectors/whatsapp_common.proto";
24+
25+
message WhatsAppCallWebhook {
26+
string object = 1; // Always "whatsapp_business_account"
27+
repeated WhatsAppWebhookEntry entry = 2;
28+
}
29+
30+
message WhatsAppWebhookEntry {
31+
string id = 1;
32+
repeated WhatsAppWebhookChange changes = 3;
33+
}
34+
35+
message WhatsAppWebhookChange {
36+
WhatsAppWebhookValue value = 1;
37+
string field = 2; // "calls" for call events
38+
}
39+
40+
message WhatsAppWebhookValue {
41+
string messaging_product = 1; // Always "whatsapp"
42+
WhatsAppMetadata metadata = 2;
43+
repeated WhatsAppContacts contacts = 3;
44+
repeated WhatsAppCall calls = 4;
45+
repeated WhatsAppError errors = 5;
46+
repeated WhatsAppStatus statuses = 6;
47+
}
48+
49+
message WhatsAppMetadata {
50+
string display_phone_number = 1;
51+
string phone_number_id = 2;
52+
}
53+
54+
message WhatsAppContacts {
55+
WhatsAppProfile profile = 1;
56+
string wa_id = 2;
57+
}
58+
59+
message WhatsAppProfile {
60+
string name = 1;
61+
}
62+
63+
message WhatsAppError {
64+
uint32 code = 1;
65+
string message = 2;
66+
string href = 3;
67+
WhatsAppErrorData error_data = 4;
68+
}
69+
70+
message WhatsAppErrorData {
71+
string details = 1;
72+
}
73+
74+
message WhatsAppStatuses {
75+
string id = 1;
76+
google.protobuf.Timestamp timestamp = 2;
77+
string type = 3; // always "call"
78+
WhatsAppStatus status = 4;
79+
string recipient_id = 5;
80+
optional string biz_opaque_callback_data = 6;
81+
}
82+
83+
enum WhatsAppStatus {
84+
WHATSAPP_STATUS_RINGING = 0;
85+
WHATSAPP_STATUS_ACCEPTED = 1;
86+
WHATSAPP_STATUS_REJECTED = 2;
87+
}

protobufs/livekit_connectors.proto

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2025 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package livekit;
18+
option go_package = "github.com/livekit/protocol/livekit";
19+
option csharp_namespace = "LiveKit.Proto";
20+
option ruby_package = "LiveKit::Proto";
21+
22+
import "connectors/whatsapp_webhook.proto";
23+
import "connectors/whatsapp_common.proto";
24+
25+
service ConnectorsService {
26+
rpc CreateWhatsAppParticipant(CreateWhatsAppParticipantRequest) returns (CreateWhatsAppParticipantResponse);
27+
28+
rpc DeleteWhatsAppParticipant(DeleteWhatsAppParticipantRequest) returns (DeleteWhatsAppParticipantResponse);
29+
30+
rpc ConnectWhatsAppCall(ConnectWhatsAppCallRequest) returns (ConnectWhatsAppCallResponse);
31+
32+
rpc RejectWhatsAppCall(RejectWhatsAppCallRequest) returns (RejectWhatsAppCallResponse);
33+
34+
rpc ListWhatsAppCalls(ListWhatsAppCallsRequest) returns (ListWhatsAppCallsResponse);
35+
}
36+
37+
message CreateWhatsAppParticipantRequest {
38+
string from_phone_number_id = 1;
39+
string to_phone_number_id = 2;
40+
optional string biz_opaque_callback_data = 3; // for logging purposes
41+
}
42+
43+
message CreateWhatsAppParticipantResponse {
44+
}
45+
46+
message DeleteWhatsAppParticipantRequest {
47+
optional string whatsapp_call_id = 1;
48+
optional livekit.connectors.WhatsAppCallWebhook call_terminate_webhook = 2;
49+
optional bool is_call_rejected = 3;
50+
}
51+
52+
message DeleteWhatsAppParticipantResponse {
53+
}
54+
55+
message ConnectWhatsAppCallRequest {
56+
string livekit_participant_identity= 1;
57+
map<string, string> participant_attributes = 2;
58+
livekit.connectors.WhatsAppCallWebhook call_connect_webhook = 3;
59+
ConnectorsDispatchRule dispatch_rule = 4;
60+
}
61+
62+
message ConnectWhatsAppCallResponse {
63+
string whatsapp_call_id = 1;
64+
}
65+
66+
message RejectWhatsAppCallRequest {
67+
optional string whatsapp_call_id = 1;
68+
optional livekit.connectors.WhatsAppCallWebhook call_connect_webhook = 2;
69+
}
70+
71+
message RejectWhatsAppCallResponse {
72+
}
73+
74+
message ListWhatsAppCallsRequest {
75+
string from_phone_number_id = 1;
76+
}
77+
78+
message ListWhatsAppCallsResponse {
79+
repeated livekit.connectors.WhatsAppCall calls = 1;
80+
}
81+
82+
message ConnectorsDispatchRule {
83+
optional string room = 1;
84+
optional string room_prefix = 2;
85+
optional string room_suffix = 3;
86+
optional string agent_name = 4;
87+
// what is metadata for agent dispath? do we need it here?
88+
}

0 commit comments

Comments
 (0)