textbee icon indicating copy to clipboard operation
textbee copied to clipboard

[Feature] Batch Sending - custom interval and delay option

Open CharlieEcho opened this issue 11 months ago • 3 comments

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,

CharlieEcho avatar Dec 18 '24 18:12 CharlieEcho

+1

gb-123-git avatar Dec 20 '24 08:12 gb-123-git

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)


flutter-painter avatar Jan 17 '25 09:01 flutter-painter

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

gb-123-git avatar Mar 02 '25 20:03 gb-123-git