Skip to content

Lk phone numbers #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Lk phone numbers #1146

wants to merge 16 commits into from

Conversation

nishadmusthafa
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Jul 28, 2025

🦋 Changeset detected

Latest commit: 0007077

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "github.com/livekit/protocol" specified in the `fixed` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@nishadmusthafa nishadmusthafa requested a review from a team August 13, 2025 17:52
@nishadmusthafa nishadmusthafa marked this pull request as ready for review August 13, 2025 17:52
string area_code = 3; // Area code (e.g., "415")
string locality = 4; // City/locality (e.g., "San Francisco")
string region = 5; // State/region (e.g., "CA")
string capabilities = 6; // Comma-separated capabilities (e.g., "voice,sms")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
string capabilities = 6; // Comma-separated capabilities (e.g., "voice,sms")
repeated string capabilities = 6; // a list of capabilities (e.g., ["voice", "sms"])

string locality = 4; // City/locality (e.g., "San Francisco")
string region = 5; // State/region (e.g., "CA")
string capabilities = 6; // Comma-separated capabilities (e.g., "voice,sms")
int64 monthly_cost_cents = 7; // Monthly cost in cents
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect other currencies going forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change

}

// ListPhoneNumberInventoryRequest - Request to list available phone numbers
message ListPhoneNumberInventoryRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a filter for capabilities here? And a provider, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to add capability in the request from the get go as we wanted to mostly focus on voice now. SMS certainly is something that should be supported when we support that as a channel.

For provider, my thought was to keep it separate from this request and be able to make config changes like which provider for which country in a different place. Right now, that is more in the cloud. My gut tells me that the implementations will look quite different between cloud and OSS for that.

// ListPhoneNumberInventoryResponse - Response containing available phone numbers
message ListPhoneNumberInventoryResponse {
repeated PhoneNumberInventoryItem items = 1; // List of available phone numbers
int32 total_count = 2; // Total number of available numbers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it practical to return the total number of all the numbers available for purchase? I assume that's a very long list and some providers may not even return the count.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think it might make sense as an optional field in case we receive it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to leave it out for now.

repeated PhoneNumberInventoryItem items = 1; // List of available phone numbers
int32 total_count = 2; // Total number of available numbers
int32 limit = 3; // Limit used in the request
int32 offset = 4; // Offset used in the request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offset would work for most providers, I guess, but I was thinking maybe a more generic string token or string next would make sense? This way we could still pass the next page number for certain providers and possibly a different kind of pagination token for others.

Comment on lines 76 to 80
string phone_number = 1; // Phone number in E.164 format (e.g., "+14155552671")
string country_code = 2; // Country code (e.g., "US")
string area_code = 3; // Area code (e.g., "415")
string locality = 4; // City/locality (e.g., "San Francisco")
string region = 5; // State/region (e.g., "CA")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields are very similar to ones in PurchasedPhoneNumber, maybe we could make a PhoneNumberInfo with all the common ones? We did this mistake with original SIP in the past by duplicating fields, adding anew new common field becomes very error-prone. So if we put it into a common struct the code can just pass it along without the need for explicit conversion of fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had a different thought here. Will make changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I went with more or less what you suggested. I added some changes to make the pricing data better.

import "google/protobuf/empty.proto";

// Public Phone Number Service - External API for phone number management
service PhoneNumberService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this makes it to OSS, do you think we could adapt it to Twilio API for example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think that's a good idea. Would take a stab at it in a later iteration. Also as I mentioned in the comment below, we might have variations in how that is implemented in cloud/oss for things like what is supported. Billing probably is not something we might support in OSS as it would be something very custom to implementation.


// PurchasePhoneNumberRequest - Request to purchase a phone number
message PurchasePhoneNumberRequest {
string phone_number = 1; // Phone number to purchase (e.g., "+1234567890")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think making it an array makes sense to allow batch orders?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I actually gave this some thought. In this iteration, I didn't really look into batching as much. This variation you suggested is one kind of batch implementation. There's also another where you can just give an area code and say you want 10 numbers and you don't care about what the numbers are. But I think definitely makes sense to make this an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing to keep in mind here is what would happen if the provider doesn't have a bulk api. We'd need to implement that additional logic. maybe we could validate to only do one in the beginning and add that capability in the future. In the immediate term, this is not an issue as bulk apis exist.

string country_code = 3; // Country code (e.g., "US")
string area_code = 4; // Area code (e.g., "415")
string national_number = 5; // National number without country code (e.g., "4155552671")
bool is_mobile = 6; // Whether this is a mobile number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other kinds? I've seen "toll-free" as a separate category as well, for example. If so, we might need an enum here.

string area_code = 4; // Area code (e.g., "415")
string national_number = 5; // National number without country code (e.g., "4155552671")
bool is_mobile = 6; // Whether this is a mobile number
string status = 7; // Current status ("active", "pending", "released")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of these states seem fixed, we probably could define most of them upfront as an enum.

string number_type = 5; // e.g., local, toll-free, national, mobile
string locality = 6; // City/locality (e.g., "San Francisco")
string region = 7; // State/region (e.g., "CA")
int64 spam_score = 8; // can be used later for fraud detection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int64 spam_score = 8; // can be used later for fraud detection
double spam_score = 8; // can be used later for fraud detection

Comment on lines 99 to 100
int64 created_at = 9; // timestamp when created
int64 updated_at = 10; // timestamp when updated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int64 created_at = 9; // timestamp when created
int64 updated_at = 10; // timestamp when updated
google.protobuf.Timestamp created_at = 9; // timestamp when created
google.protobuf.Timestamp updated_at = 10; // timestamp when updated

We should use Timestamp type in the new protos, since it's always unclear in which units the int timestamp is.

Comment on lines 124 to 125
int64 released_at = 4; // Timestamp when the number was released (if applicable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int64 assigned_at = 3; // Timestamp when the number was assigned
int64 released_at = 4; // Timestamp when the number was released (if applicable)
google.protobuf.Timestamp assigned_at = 3; // Timestamp when the number was assigned
google.protobuf.Timestamp released_at = 4; // Timestamp when the number was released (if applicable)

int32 total_count = 2; // Total number of available numbers
int32 limit = 3; // Limit used in the request
int32 offset = 4; // Offset used in the request
string next_page_token = 2; // Token for next page (empty if no more pages)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should make a new TokenPagination in the livekit_models.proto, similar to existing Pagination. It will allow us to write a generic pagination code an reuse it for all models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants