Feature request: Leave off computer name when issuing an Alexa command

  • I don't know if it would be possible, as I'm not sure how the Alexa Skills API actually works, but it would be nice if I could designate one of my registered computers as the default for Alexa commands, so instead of saying, "Alexa, tell Trigger C M D lock on computer," I could just say, "Alexa, tell Trigger C M D lock," and it would trigger it on the designated default machine. (Actually, as I currently only have one machine registered with TRIGGERcmd, it would be the de-facto default.)

  • @Christian-Robinson I think that's possible, and it's a good idea.

    The Alexa part should be easy. The harder part will be to provide a way to designate a default computer, but I'm sure it's possible.

  • You could possibly make it so there could be a default on a per-command basis:


    But that raises the question of what to do if someone makes a mistake and tries to default the same trigger on multiple machines.

    Edit: On consideration, you could allow multiple defaults, and they would all be triggered. I can envision a case where, for example, I would want to be able to suspend or power down several computers with one command.

  • @Christian-Robinson , I thought the idea was to have a default computer, so you could say, "run lock" and it would run the command with "voice":"lock" on your default computer.

    That makes more sense than default commands.

    Here's an idea related to your Edit though - I could allow the user to say, "run lock on all computers". It would only run on the computers that have a command with "voice":"lock" of course. It's a very different use-case from your original idea of being able to say, "Alexa, tell Trigger C M D run lock".

  • I was just musing on ideas on how to specify a default, and wondering aloud whether it's better to have just a default computer or make individual commands have a default--that is, command "abc" could be default to computer "xyz," while command "123" would be default to computer "789". That led me to wonder what would happen if you tried to make "abc" default on both "xyz" and "123" and what the solution would be to that problem. Ignore it, or allow it to trigger on both, or something else?

    I like your "on all computers" idea, but that makes me wonder about the possibility of groups. Although I don't imagine anybody would typically have more than two or three computers set up with this system, if someone had several they might want to be able to group them together. For example group "Home" and group "Work." "Alexa tell Trigger C M D lock on group Home."

    But this is getting afield of my original suggestion, which is to be able to just invoke the command without a specification of which machine(s) to trigger on, which would be the most useful to me right now, whichever way you want to implement it if you choose to do so.

  • I'll have some time this weekend to work on this.

    Here's a couple other ideas I'd like your opinion on:
    1. I could include a command-line utility with the agent that allows you to trigger a command on a computer.

    Something like this: triggercmd --trigger Reboot --computer "Office PC"

    The only downside I see is users might make a trigger that triggers itself, so you'd have an infinite loop that seriously taxes my server. I'd need some sort of throttle to prevent that.

    I think it would be cool to run a command on a Windows PC that runs a command on a remote Mac, or Raspberry Pi...

    2. I could also have the command-line utility take a parameter:
    Something like this: triggercmd --trigger Reboot --computer "Office PC" --param "60"

    For security, I'd want to strip out any characters that could be used to run a separate command on the remote computer, like |, &, and ; .

  • @Russ, The most obvious way to prevent it form stressing your server is a throttle system. Simplest is to refuse to run too many commands in a row without a delay between them. That wouldn't solve the problem of an infinite loop mistake, though, and preventing those seems far more tricky to me. I can imagine this might frustrate people who want to "chain" triggers, but that's not really the right way to do it; they should be writing a shell, batch, or whatever script that does everything on a single trigger.

    Allowing parameters is something I think you should avoid, since it's too likely to create security holes even if you try to sanitize input. You definitely need to strip out shell meta-characters such as $, *, ?, {}, (), [], quotes, and so on, especially since some shells like Bash and zsh have some mind-boggling extra expansion capabilities.

    If you really want to do it, I suggest forcing the user to explicitly specify allowed parameters in the json config file:


    So triggering "foo" is only allowed to have some combination of "bar", "baz", "qux", and "etc" passed to it. It wouldn't stop the user from shooting themselves in the foot if they were determined to, but it'd make it harder, and shift the responsibility to them.

  • @Christian-Robinson, this is more good input.

    I didn't even think of that use-case of chaining commands. That could be useful, especially when you want the next command in the chain to run on a different computer.

    My original idea was to avoid parameters because of the potential security risk. Your idea of limiting the options for those parameters makes sense, but I figure if you want to be able to run foo bar and foo baz, you could make two commands. I'll probably keep it simple and nix the parameter idea.

    Thanks again.

  • @Christian-Robinson, I added the default computer field in your Profile page. As soon as Amazon approves my update to the Alexa skill, you'll be able to use it like this:

    "Alexa, tell TRIGGERcmd run Calculator"
    "Alexa, open TRIGGERcmd"
    "run Calculator"

    It will run the command with voice word "calculator" on your default computer.

    Thanks again for the suggestion.

  • Amazon approved the skill update.

  • @Russ Unfortunately it's not working. I can still do "Alexa, tell TRIGGER c m d [command] on Windows," and it works fine, but if I leave the "on Windows" part off Alexa always says "Could not find a trigger called undefined on [...]"

    Edit: Perhaps it has something to do with the fact that I have a different name and voice trigger name for my Windows machine? For Alexa I just call it "Windows" but in my profile it's called "Arrietty". I had to set the default name in my profile to "Arrietty" or Alexa would tell me it could not find the device.

  • Yes, that's it. You have to give it the computer name, not your voice trigger name.

    I think other people will do the same, so I'll try to make that clearer in the interface.

    Although it said your trigger is undefined, so I'm still confused.

  • @Russ Unfortunately it just doesn't work either way. Giving it the voice name gives an overall error (can't find the device, or something like that), but giving it the computer name always gives the "Could not find a trigger called undefined on Arrietty" error.

  • I have a theory. You have two of the same command. I think you got those when the agent still had that bug. Can you rename that command in your commands.json and see if the problem goes away?

  • @Russ Unfortunately I still get the "undefined" response. Also, duplicates still appear on me occasionally--when I notice it I use the rename trick to clear them, but didn't see that one.

  • Ok. I appreciate your patience. I'll try to reproduce these two problems. I thought I fixed the duplicate commands problem in v1.0.5 of the Windows agent.

    Are you saying the word, "run" before your trigger's voice word?

  • I reproduced it!

    I said, Alexa, tell trigger c m d, Calculator.

    Alexa said, cannot find a trigger called "undefined" on RussFam.

    Sweet. I can fix this.

  • @Russ No, I wasn't saying "run," but when I do it works.

  • @Christian-Robinson

    Awesome. Thanks for showing me another bug. I'll do an update to the Alexa skill to allow a single word to represent the trigger's voice word to run on your default computer.

  • @Russ No problem. I'm happy to help, especially since this is such a cool skill. Thank you for your efforts.

Log in to reply