Setting and sending text input from a scene in Tasker

This will open up a plethora of opportunity for server-side processing, like sending to IFTTT to integrate with other web apps.

Here’s how you do it

From the Variables tab, add a variable. I’m calling mine: %ForSend

  • From the Scenes tab, tap the add/plus button in the bottom-right corner and name your scene.
  • Tap the zoom button in the bottom right
  • Tap the plus button, or long-press to reach the ‘add element’ menu, and choose ‘TextEdit’.
  • Name the element if you want.
  • On the ‘TEXT CHANGED’ tab, add a Task: choose ‘Variable Set’.
  • Type or select the variable you made earlier for the ‘Name’ field (‘%ForSend’). For the ‘To’ field, use ‘%new_val’.

Now the variable will get set whenever you type something new, but you probably want to do something with this value. I’m going to:

…though you might want to do something else on your button-tap.

  • Go back to the scene and add a new element of type ‘button’
  • Give it a label. E.g. ‘Send it’
  • From the ‘Tap’ tab, add a task. (Here’s where you might want to divert to do something other than send the data to a URI). I’m sending to: ‘http://shass.co/sender’ in the below setup, so I chose: ‘HTTP post’ (Under ‘Net’)

Now you’ll probably want to be able to bring up your scene somehow…

Let’s make an icon for the homepage to open the scene.

  • Back your way out of the Scene editing, and add a new Tasker task.
  • Add action: ‘Show scene’ (under ‘Scenes’). Chose your scene and configure as you desire. I set the ‘Display As’ to: ‘Dialog’, and shifted the ‘Vertical Position’ up a little so the soft keyboard doesn’t cover my send button.
  • Go up to view your Add an Icon for your Task by tapping icons icon which is at the centre of the bottom panel.
  • Add the Tasker shortcut for this Task. (If you don’t know how to do this, I don’t believe you actually bought Tasker.)

Bonus: Some things to improve the User Experience (even if that user is you. You deserve it!):

  • I’m also adding four actions in the Scene’s Button ‘Tap’ section for some visual user feedback:
  1. A ‘Flash’ alert (under ‘Alerts’) to indicate the sending happening (move this to before the HTTP post.)
  2. Another flash alert to indicate sending is complete! (Homework assignment: only show this if the HTTP post was successful.)
  3. The Third is to clear the value of the TextBox: Add the new action of type ‘Element Text’ (under ‘Scene’), and in the ‘Element’ field, find your text element.
  4. Fourth, a ‘Destroy Scene’ action, which will close the dialog after sending.

And here it is:

Testing the button, I can see in my apache log that the endpoint was called successfully from Tasker:

🍻

then you can’t come back