Skip to content
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

[Feature] Batch Sending #32

Open
CharlieEcho opened this issue Dec 18, 2024 · 3 comments
Open

[Feature] Batch Sending #32

CharlieEcho opened this issue Dec 18, 2024 · 3 comments

Comments

@CharlieEcho
Copy link

Some mobile providers restrict the number of SMS messages that can be sent at a time. Could we add a batch amount and and interval timer as an option?

Default remains how the app currently operates, and a Custom option for SMS Batch Quantity and Interval (in seconds).

VBR,

@gb-123-git
Copy link

+1

@flutter-painter
Copy link

How about handling this in your code sending logic ?
Below is a ruby snippet that puts a random interval 3-10 seconds between each sms :

def send_sms(device_id, api_key, phone_numbers, message)
  uri = URI.parse("https://api.textbee.dev/api/v1/gateway/devices/#{device_id}/send-sms")
  header = {
    'x-api-key': api_key,
    'Content-Type': 'application/json'
  }

  phone_numbers.each do |number|
    body = {
      recipients: [number],
      message: message
    }.to_json

    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    request = Net::HTTP::Post.new(uri.request_uri, header)
    request.body = body

    response = http.request(request)
    puts "Sent SMS to #{number}: #{response.code} - #{response.message}"
     # Add varying delay between 3 to 10 seconds 
     delay = rand(3..10) 
     puts "Waiting for #{delay} seconds before sending the next SMS..." 
     sleep(delay)
  end
end

api_key = 'YOUR_API_KEY'
device_id = 'YOUR_DEVICE_ID'
phone_numbers = ['+XXXXXXX', '+XXXXXXX']
message = 'textbee is super cool'

send_sms(device_id, api_key, phone_numbers, message)

@gb-123-git
Copy link

@flutter-painter
Nice ! but it would be even nicer to handle this server side with configurable options in UI. :)

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

No branches or pull requests

3 participants