No internet connection
  1. Home
  2. Questions

Text Status Not working inside of DataReader ForEach

By @enum2021-04-21 19:56:36.810Z2021-04-22 14:14:28.151Z

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.

Solved in post #5, click to view
  • 5 replies
  1. L
    Liam @liam2021-04-29 08:22:16.959Z

    Hi

    Can you provide a screenshot of the list of automation actions that you have set up and are running, please?
    I can attempt to do a similar thing to see if I also get the same problem.

    1. E
      In reply toenum:
      @enum2021-04-29 13:13:29.908Z2021-05-03 13:12:12.855Z
      1. LLiam @liam2021-05-04 12:23:56.669Z

        I've reproduced the problem, though I couldn't see an actual error being produced.
        I've sent this over to the developers as a bug.
        I can't say when a fix might be available while this is in Beta.

      2. S
        In 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
        -Twilio Call

        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.

        Thanks
        Stephen

        ReplySolution
        1. E@enum2021-05-04 12:50:45.797Z

          Awesome, Thank you Stephen! I definitely had thought of calling a new automation to process each text and that is what I will do. I am glad this information is now documented and that it will also be documented inside of TA.