Hello Think Automation community,
I am back again with another issue with Twilio.
In my automation, I am opening a Database Reader and starting a ForEach loop with the intent to send a survey via text.
The problem is with the text status returning. When I run the loop without trying to get the text status it runs fine. When
I try to get the status, the loops errors out and only runs for the first record in the database.
the error is: "No data reader for For Each TextsToSend"
TexstsToSend is the name of the variable that the database record json goes into
Another small detail that may be important is the variable is tested right after the text command and it is not showing it has a value,
even though in the automation results it says the value was set to delivered.
I can do this exact block of code outside of the loop and it runs correctly, but inside the loop the variable is not set and the loop errors out.
Here is my setup for the text:
I can answer any other setup questions if needed.
Edit: I wanted to add that I believe this is a synchronization error where the automation isn't waiting for the status inside of a foreach loop using a Database Reader.
- 5 replies
- SIn reply toenum⬆:Stephen Parker @stephenparker2021-05-04 12:42:37.251Z
This is a limitation of the Data Reader/ForEach action. The following action types cannot be used inside a DataReader/ForEach block:
-Wait For User Response
-Wait For Webhook
-Twilio SMS (when waiting for status)
-Twilio Wait For SMS Reply
The reason is that these actions cause the Automation to pause - and the message processor to move on to the next message. After the response is received the message processor resumes the Automation where it left off. However for DataReader/ForEach blocks the underlying data my have changed in the mean time which would invalidate the loop - and it would be unable to keep each data reader open - since there could in theory be thousands of messages in a waiting state.
The way around this would be to do it a different way, such as:
- Use the Call action inside the for each block to Call another automation but disable the 'Wait For Completion' option on the call action. Each call would then execute as its own message.
- Use the Database Pull message source type instead.
- Inside the For Each block, write the Json of the Data Reader row to a text file - and have another File Pickup Message Source to process these.
We will update the Studio to validate the actions so that the Automation cannot be saved if the above actions are added inside a DataReader/ForEach block.