SMS Sending Exception

109 views
Skip to first unread message

stephane boyera

unread,
Apr 30, 2025, 12:11:23 PM4/30/25
to Automate for Android
Hi,
I'm using the SMS Send block and I've some issue. 99% of the time everything goes smoothly. but from time to time I got errors. The catch failure block I put to detect issue always returns : com.llamalab.android.telephony.SmsSendException: Unknown error (0)
I'm not sure how I should interpret the issue? 
I've at least two potentiel sources of error:
1- the fact that the phone number is no more functionning (e.g. one of my contact changed phone number without telling me)
2- the fact that I ran out of credit in my prepaid account

Is there a way to know what is the exact issue the block encountered?

Thanks in advance
best
steph

Henrik "The Developer" Lindqvist

unread,
May 1, 2025, 8:35:25 AM5/1/25
to Automate for Android
Sadly the Android error reporting is very poor, e.g. "Unknown error", so knowing the cause is difficult. Usually it's some connectivity problem.
Use the Failure catch block to handle the error, e.g. retry after a few minutes.

stephane boyera

unread,
May 1, 2025, 12:40:00 PM5/1/25
to Automate for Android
Hi Henrik, 
Thanks for the answer. That was my fear! perhaps i should use a mobile service state before trying to send to be sure that the network is up? and for testing credit i don't have much choice just running from time to time a ussd request block to ensure there is credit. That should remove the usual issue, the last one that should generate issue is then likely a wrong number? does that make sense?

thanks again
best
steph

Henrik "The Developer" Lindqvist

unread,
May 1, 2025, 2:51:33 PM5/1/25
to Automate for Android
No, just handle the failure instead, since it could occur anyway.
Try using Proceed= When sent or When delivered then the error reporting may tell if it's a wrong number.

stephane boyera

unread,
May 5, 2025, 12:36:49 PM5/5/25
to Automate for Android
I went on during a series of test, without much success:
*putting the SMS send block with the mode 'When sent' does not help detecting wrong numbers (returns success for unassigned number), but helps detect badly formed number (even if it is an unknown error)
*putting the sms send block with the mode 'when delivered' is perfect for detecting wrong number (not assigned ones) as you get the error 'com.llamalab.android.telephony.SmsPermanentDeliveryException: Incompatible destination'. I'm pretty sure even if i cannot test it right now that it is also the best option to detect a lack of credit on pre-paid subscription. But the issue here is that you block your flow till the sms is delivered to the remote device. ie if someone turns off his phone for 2 days, you flow will stop 2 days, which could be problematic. 
I've a couple of questions here: i could easily use a fork to wait for the end of the block, but i suspect that the pilling up of forked process could quickly fill the memory of the phone? how many running fork could a phone handle ?
The other option would be to wait only like a few second to ensure that we did not get an error message and proceed. Is there a way to tell automate to move to next block after a few second of a block being stopped?

I also tested and validated the fact that if you try to send a sms while the GSM connectivity is down, the block will not detect the absence of network and stay stuck, even after the network is back. The best option (as far as i can tell) to solve the issue is to put a mobile service state before the sms send and test if it is in service. if no, you put another mobile service state and wait for service to become available again.

best
steph

Henrik "The Developer" Lindqvist

unread,
May 6, 2025, 12:48:04 PM5/6/25
to Automate for Android
Automate can probably handle millions of forks since they're just data saved on disk, but awaiting a SMS delivery report involve other system resources which are limited to a few hundred.
Use the Fiber stop block to stop a fork, e.g. at an SMS send block awaiting its delivery report.
Reply all
Reply to author
Forward
0 new messages