Help on debugging custom Siri shortcuts

By peter, 29 October, 2018

Forum
iOS and iPadOS

Okay, I was inspired by the AppleVis podcast on creating custom shortcuts, so I started creating my own.

Although most of it just involves slogging through the actions and experimenting to get used to the system, the biggest question I have is how to debug shortcuts one is developing.

For example, I can read in variables, set variables, change variables, etc. But is there an easy way to display variables either one at a time or several at once so that I can debug the shortcut as it is being written?

I tried the Quick View Action, but that only seems to take input from a file. What I really want is some way of simply displaying variables as they are changed along the way.

Thanks for any hints or suggestions.

--Pete

Options

Comments

By Dave Matters on Monday, November 26, 2018 - 10:24

Add an alert after the point you want to check the contents of a variable, and include the variable in the alert using a magic variable. Then you can use the ok button to continue the shortcut or cancel if you want to abort it at that point. Once you are getting the results you are getting you can remove the alert(s). Hope this helps.

By peter on Monday, November 26, 2018 - 10:24

I tried the "Show Alert" action with no success. Here are the issues I ran into. Maybe I'm doing something wrong:

1. I see an edit field for the Title and one for the text. I don't think this is where I can include a magic variable, but if I can, I don't know how to do that with VoiceOver.
2. On the "Show Cancel Button" one can do a single finger double tap to toggle this to "on" or "off". That works okay.
3. Also on the "Show Cancel Button" one can flick up/down and come to an action that says "Choose Variable". So I get into that and see a list odfof variables defined in my shortcut. If I select one or select the Magic variable, when this dialog is closed I then see the "Show Cancel button" but it doesn't show the "on" / "off" status.
4. Now, if I run the shortcut, the Alert appears with the title and text, but:
a. There is no "Cancel" button, only an "OK" button.
b. I don't see the selected variable.

Thus I can't find a way to cancel the shortcut at this point and don't see the selected variable that I want to see.

Perhaps there is another way of getting a variable into the text box with VoiceOver?

Thanks for any advice.

--Pete (stumped)

By Dave Matters on Monday, November 26, 2018 - 10:24

It sounds like what you ended up doing is picking your variable to be used to determine if the cancel button should be displayed. Go back to the action option for the cancel button. Make sure the rotor is set to action. Select the select variable option again, and this time tap clear. This should give you the on/off button again. Then just make sure it is set to on.

As for the variable in the alert action, get into either the title or text box. Once there you should be able to input a variable by choosing it from the top of the keyboard, or opening the variable drawer. I believe when it is added to the text box it is reported as an attachment with voiceover.
Let me know if this helps.

By peter on Monday, November 26, 2018 - 10:24

Dave,

Thanks for the tip. After scouring the screen by moving my finger around, I finally found an item above the keyboard that was labeled "Variables" when in an edit field. Activating the "Variables" button gave me the ability to add a variable to the edit field at the current location in the edit field. This is a nice way of mixing text and variables into the edit fields that can later be displayed with the Show Alert action for debugging or other purposes.

Unfortunately, I couldn't see with VoiceOver how to distinguish ordinary text in an edit field from a variable in the edit field. You indicated that the variable might have the label "attachment", but I didn't hear this with VoiceOver.

Anyway, this solves my problem and now I can view several variables along with text descriptions in the edit field to debug and verify input/outputs and transformations.

Thanks a bunch.

--Pete

By Deborah Armstrong on Tuesday, February 26, 2019 - 10:24

I found it helpful to create a shortcut that does a single thing; gets one input, transforms it and creates output before moving on to doing a more complex shortcut that might be actually something I want. For example I got the forecast from http://braille.wunderground.com and just had the phone speak it though I actually wanted to create a shortcut ultimately that did something far more complicated with a different URL. The full user guide from Apple is here:
https://support.apple.com/guide/shortcuts/welcome/ios

By peter on Tuesday, February 26, 2019 - 10:24

Yes, as the author points out, it is always better to take baby steps and build one step at a time on that....Especially if you are new to coding or scripting!

Also, it can be very useful to look at what others have done (i.e., work with some shortcuts which are already written in the Shortcuts Gallery) and use some of what you see as starting templates for your own custom scripts.

--Pete

By gailisaiah on Tuesday, February 26, 2019 - 10:24

Sorry if this isn't the place to ask this. But I created a shortcut called "Repeat" used with Apple Music. So I thought it would only work when I said something like, "Repeat this song". But everytime I start to play a song on Apple Music either from my Library or something else, it always is on repeat unless I ask Siri "Turn off repeat." I went in to the shortcut and thought I deleted it but I did not. Now every time I start a song, I have to tell Siri to "Turn off repeat". Any suggestions? Thank you.

By Deborah Armstrong on Tuesday, February 26, 2019 - 10:24

Find it in the shortcuts list, flick up, choose remove.

By viphoana on Wednesday, February 26, 2020 - 10:24

I use quicklook quite successfully. It accepts any input. I also sometimes use the "show alert" to display the variables because this way I can choose to resume or stop the shortcut. Use the rotor to edit input of quicklook. Magic variables are also very useful. hth.