If you missed my 1st live stream you can watch the entire thing in this link. It takes you through the process of creating a task to select the 20 winners at random. The process was messy and flawed with usual tasker problems but viewers claimed I was entertaining at times. This also shows you how much time sometimes you have to spend to figure something out. If it was an already made tutorial it would take me about 3-4min after the edit. I wanted to be unprepared. Thanks, all of you guys for coming and helping me out with all the issues.
If you curious how the task works here is the rundown. I want to get all the people in one list, then use random action, to pick a random number which will correspond to the array element. In addition to that, I want the array to be shuffled to give extreme positions (end.start) better chances as well. Each time a winner is picked, a code is emailed, and the winner is removed from the list.
Rinse and repeat 20 times
Livestream 1:28:00 is where the task runs and picks the winners.
The form with your submissions contains the name, email address and newsletter option. We obviously don’t need the last one. As we are going to shuffle the array elements we have to merge the name and email address together.
I will have 3 actions to create relevant arrays and one loop to create a list to contain the name,address array.
A thing I struggled for a while was splitting the names by ENTER. The way to go is to create a variable %Enter and set it to ENTER. Then simply split by this variable. The actions A1-A7 create 3 arrays containing: name, address, code.
We need a FOR loop to assign a %Result – an array that will store the name,address. For each element of array with the name %WinName we will set a variable %WinName(%count),%WinEmail(%count). Each time the loop is performed %count will increase by 1 until we have no more names left.
AllPeople (30) A1: Variable Set [ Name:%Enter To: Recurse Variables:Off Do Maths:Off Append:Off ] A2: Variable Set [ Name:%WinName To: Recurse Variables:Off Do Maths:Off Append:Off ] A3: Variable Set [ Name:%WinEmail To: Recurse Variables:Off Do Maths:Off Append:Off ] A4: Variable Set [ Name:%Codes To: Recurse Variables:Off Do Maths:Off Append:Off ] A5: Variable Split [ Name:%Codes Splitter:%Enter Delete Base:On ] A6: Variable Split [ Name:%WinEmail Splitter:%Enter Delete Base:On ] A7: Variable Split [ Name:%WinName Splitter:%Enter Delete Base:On ] A8: Variable Set [ Name:%count To:1 Recurse Variables:Off Do Maths:Off Append:Off ] A9: For [ Variable:%Result Items:%WinName() ] A10: Variable Set [ Name:%joined To:%WinName(%count),%WinEmail(%count) Recurse Variables:Off Do Maths:Off Append:Off ] A11: Array Push [ Variable Array:%ReadyList Position:1 Value:%joined Fill Spaces:On ] A12: Variable Add [ Name:%count Value:1 Wrap Around:0 ] A13: End For
Email and Code task
Our %Codes array contains 20 entries. Each time a winner is picked we want to take one code and enter it in an email. Because this task will be run by a Perform Task action, we will have 2 variables %par1 and %par2 available. One will contain an email and one the name of the person. When an email is composed, it also uses a %winnercode from the Array Pop action to assign a winning code. Then AutoInput sends the email for us. As you could see in the stream I had an issue with it as streaming screen on my PC caused issues with the AI.
Codes (32) A1: Array Pop [ Variable Array:%Codes Position:1 To Var:%winnercode ] A2: Compose Email [ Recipient(s):%par2 Subject:Congratulations! You won! Message:Hello %par1 You have won a code for the Minimal & Elegant watch face. Here is the code: %winnercode Please claim the code before 30th April. Thank you and see you around soon. ] A3: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] A4: AutoInput Action [ Configuration:Type: Text Value: Send Action : Click Timeout (Seconds):20 ] A5: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
Picking the winners
We have a list of people, and we want the task to run 20 times. I will set up a simple timer %count20 in conjunction with GOTO action using labels. Variable %ReadyList(#) gives us a current number of people in the array, each time we pick one winner, we have to make sure this list is updated (array pop) mixed (array process) and the winner is picked at random (Variable randomise). When the winning entry is picked, it is split into 2, %WinnersNamEm(1) and %WinnersNamEm(1) – then these values are used in Perform Task as %par1 and %par2. Each time the winner is picked, the Email and Code task is executed.
Pick a winner (31) A1: Variable Set [ Name:%count20 To:1 Recurse Variables:Off Do Maths:Off Append:Off ] A2: Variable Set [ Name:%NumberOfPpl To:%ReadyList(#) Recurse Variables:Off Do Maths:Off Append:Off ] A3: Variable Randomize [ Name:%AWinner Min:1 Max:%NumberOfPpl ] A4: Array Pop [ Variable Array:%ReadyList Position:%AWinner To Var:%WinnersNamEm ] A5: Array Process [ Variable Array:%ReadyList Type:Shuffle ] A6: Variable Split [ Name:%WinnersNamEm Splitter:, Delete Base:On ] A7: Perform Task [ Name:Codes Priority:%priority Parameter 1 (%par1):%WinnersNamEm(1) Parameter 2 (%par2):%WinnersNamEm(2) Return Value Variable: Stop:Off ] A8: Variable Add [ Name:%count20 Value:1 Wrap Around:0 ] A9: Goto [ Type:Action Label Number:1 Label:starthere ] If [ %count20 < 21 ]
Thank you all for participating, all winners have been emailed. Congratulations to:
- James Barnes
- Parth Temkar
- Sarah Whitekiller
- Mihir Gohad
- Jason Bishop
- Stephen Gower
- Michael Epiney
- Justin Somermeyer
- Mark Roedel
I will try to organise another giveaway soon, so keep in touch!