textbee
textbee copied to clipboard
[Feature] Batch Sending - custom interval and delay option
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,
+1
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 Nice ! but it would be even nicer to handle this server side with configurable options in UI. :)