Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions im/api/gateway/v1/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ message SendTextRequest {

// Set by providers when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 23;

map<string, string> variables = 24;
}

// Represents a response to send a text message.
Expand Down Expand Up @@ -312,6 +314,11 @@ message SendDocumentRequest {

// Set by providers when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 23;

// Variables seeded onto the thread when this message is the one that creates
// it; ignored on every later message. Providers fill it from the channel's
// first-message payload so a flow schema can route on the caller's own data.
map<string, string> variables = 24;
}

// Represents a response to send message with document.
Expand Down Expand Up @@ -374,6 +381,12 @@ message SendLocationRequest {

// Set by providers when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 10;

// Platform message id, when the channel reports one.
string external_id = 11;

// ID of the message this is a reply to, as reported by the external channel.
string reply_to_external_id = 12;
}

// SendContactRequest sends contact information.
Expand Down Expand Up @@ -405,6 +418,12 @@ message SendContactRequest {

// Set by providers when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 9;

// Platform message id, when the channel reports one.
string external_id = 10;

// ID of the message this is a reply to, as reported by the external channel.
string reply_to_external_id = 11;
}

// SendInteractiveMessageRequest sends a structured interactive message.
Expand Down
3 changes: 2 additions & 1 deletion im/api/gateway/v1/message_history.proto
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ message Image {
}

message ReplyToMessage {
string id = 1;
string message_id = 1;
ThreadMember sender = 2;
string sender_id = 3;

Expand All @@ -249,6 +249,7 @@ message ReplyToMessage {
optional string attachment_name = 8;
optional string attachment_mime = 9;
optional string attachment_address = 11;

bool is_deleted = 10;
}

Expand Down
33 changes: 33 additions & 0 deletions im/service/provider/v1/custom_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";

package webitel.im.provider.v1;

import "google/api/annotations.proto";
import "service/provider/v1/entities.proto";
import "service/provider/v1/messages.proto";

option go_package = "github.com/webitel/im-provider-service/gen/go/api/v1;impb";

/// CustomService defines the RPC methods for managing custom chat gateways —
/// arbitrary external communication systems connected as a chat channel.
service CustomService {
/// CreateCustomGate registers an external system as a messaging gateway.
rpc CreateCustomGate (webitel.im.provider.v1.ProviderCreateCustomGateRequest) returns (webitel.im.provider.v1.ProviderCreateCustomGateResponse) {
option (google.api.http) = { post: "/im/gates/custom", body: "*" };
}

/// GetCustomGate retrieves configuration and status for a custom gateway.
rpc GetCustomGate (webitel.im.provider.v1.ProviderGetCustomGateRequest) returns (webitel.im.provider.v1.ProviderGetCustomGateResponse) {
option (google.api.http) = { get: "/im/gates/custom/{id}" };
}

/// UpdateCustomGate updates custom gateway settings.
rpc UpdateCustomGate (webitel.im.provider.v1.ProviderUpdateCustomGateRequest) returns (webitel.im.provider.v1.ProviderUpdateCustomGateResponse) {
option (google.api.http) = { patch: "/im/gates/custom/{id}", body: "*" };
}

/// DeleteCustomGate removes the custom gateway integration.
rpc DeleteCustomGate (webitel.im.provider.v1.ProviderDeleteCustomGateRequest) returns (webitel.im.provider.v1.ProviderDeleteCustomGateResponse) {
option (google.api.http) = { delete: "/im/gates/custom/{id}" };
}
}
18 changes: 18 additions & 0 deletions im/service/provider/v1/entities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,21 @@ message ProviderTelegramBotGate {
int64 created_at = 7;
int64 updated_at = 8;
}

message ProviderCustomGate {
string id = 1;
string name = 2;
string webhook_url = 3;
// Customer-side webhook Webitel posts operator replies and events to.
string callback_url = 4;
// Shared secret used to sign and verify X-Webitel-Sign in both directions; handled as sensitive.
string app_secret = 5;
// Optional CIDR allowlist; an empty list accepts any source address.
repeated string allowed_ips = 6;
int32 request_timeout_ms = 7;
int32 retry_attempts = 8;
webitel.im.provider.v1.ProviderStatus status = 9;
int64 created_at = 10; // Unix timestamp in milliseconds
int64 updated_at = 11; // Unix timestamp in milliseconds
bool enabled = 12;
}
1 change: 1 addition & 0 deletions im/service/provider/v1/enums.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum ProviderType {
PROVIDER_TYPE_FACEBOOK = 5;
PROVIDER_TYPE_INSTAGRAM = 6;
PROVIDER_TYPE_WHATSAPP = 7;
PROVIDER_TYPE_CUSTOM = 8;
}

/// ProviderStatus represents the operational state of a provider gateway.
Expand Down
42 changes: 42 additions & 0 deletions im/service/provider/v1/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,48 @@ message ProviderUpdateViberGateResponse {
message ProviderDeleteViberGateRequest { string id = 1; }
message ProviderDeleteViberGateResponse { webitel.im.provider.v1.ProviderViberGate item = 1; }

message ProviderCreateCustomGateRequest {
string name = 1; // Name of the gateway in Webitel
Peer peer = 2; // Webitel bot identity (sub and iss) the channel routes inbound messages to
string callback_url = 3; // Customer-side webhook; must be an absolute https URL
string app_secret = 4; // Shared signing secret; generated when empty
repeated string allowed_ips = 5; // Optional CIDR allowlist
int32 request_timeout_ms = 6; // Timeout of a single callback attempt; defaults when zero
int32 retry_attempts = 7; // Retries before a message is marked failed; defaults when zero
bool enabled = 8;
}

/// ProviderCreateCustomGateResponse returns the newly activated custom provider.
message ProviderCreateCustomGateResponse {
webitel.im.provider.v1.ProviderCustomGate item = 1;
}

/// ProviderGetCustomGateRequest fetches a custom provider configuration.
message ProviderGetCustomGateRequest { string id = 1; }
message ProviderGetCustomGateResponse { webitel.im.provider.v1.ProviderCustomGate item = 1; }

/// ProviderUpdateCustomGateRequest updates custom gateway settings.
message ProviderUpdateCustomGateRequest {
string id = 1;
string name = 2;
Peer peer = 3; // Webitel bot identity (sub and iss)
string callback_url = 4;
string app_secret = 5; // New signing secret, if rotated
repeated string allowed_ips = 6;
int32 request_timeout_ms = 7;
int32 retry_attempts = 8;
bool enabled = 9;
}

/// ProviderUpdateCustomGateResponse returns the updated custom provider.
message ProviderUpdateCustomGateResponse {
webitel.im.provider.v1.ProviderCustomGate item = 1;
}

/// ProviderDeleteCustomGateRequest removes the custom integration.
message ProviderDeleteCustomGateRequest { string id = 1; }
message ProviderDeleteCustomGateResponse { webitel.im.provider.v1.ProviderCustomGate item = 1; }

// --- Generic Discovery & Resource Management ---

/// ProviderListGatesRequest contains pagination and filtering logic for discovering providers.
Expand Down
3 changes: 2 additions & 1 deletion im/service/thread/v1/message_history_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ message System {
}

message ReplyToMessage {
string id = 1;
string message_id = 1;
string sender_id = 2;

reserved 3;
Expand All @@ -191,6 +191,7 @@ message ReplyToMessage {
optional string attachment_name = 7;
optional string attachment_mime = 8;
optional string attachment_address = 10;

bool is_deleted = 9;
}

Expand Down
20 changes: 20 additions & 0 deletions im/service/thread/v1/message_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ message SendTextRequest {

// Set when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 23;

// Variables seeded onto the thread when this message is the one that creates
// it; ignored on every later message.
map<string, string> variables = 24;
}

// Represents a response to send a text message.
Expand Down Expand Up @@ -292,6 +296,10 @@ message SendDocumentRequest {

// Set when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 23;

// Variables seeded onto the thread when this message is the one that creates
// it; ignored on every later message.
map<string, string> variables = 24;
}

// Represents a response to send message with document.
Expand Down Expand Up @@ -360,6 +368,12 @@ message SendLocationRequest {

// Set when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 12;

// Platform message id, when the channel reports one.
string external_id = 13;

// ID of the message this is a reply to, as reported by the external channel.
string reply_to_external_id = 14;
}

// SendContactRequest sends contact information.
Expand Down Expand Up @@ -397,6 +411,12 @@ message SendContactRequest {

// Set when the channel reports this message was forwarded to us.
optional ForwardOriginInput forward_origin = 12;

// Platform message id, when the channel reports one.
string external_id = 13;

// ID of the message this is a reply to, as reported by the external channel.
string reply_to_external_id = 14;
}

message SendSystemMessageRequest {
Expand Down
2 changes: 1 addition & 1 deletion swagger/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -71253,7 +71253,7 @@
"type": "string",
"format": "int64"
},
"id": {
"message_id": {
"type": "string"
},
"is_deleted": {
Expand Down
Loading