How to Run Mix It Up Commands from Touch Portal and UP Deck

Date: 15 May 2020

Mix It Up app is a fantastic tool for making streaming easier. It gives you powerful tools for chat, overlays, Twitch Channel Points and more. What it doesn’t have is a remote client that allows one to run commands from a phone or tablet. This is how I was able to combine MIU with Up Deck and Touch Portal to get the best of both worlds.

MIU lets you do really complicated things which can be triggered by a single command. You can trigger them from chat, Twitch Channel Points, or anything that can make HTTP POST requests.

Note that this is a bit of an advanced topic. I assume that you already have Mix It Up and Touch Portal or Up Deck installed and working. Don’t bother with this until you get those tools working.

Turn on the Developer API in MIU

The first thing you need to do is enable the Developer API in Mix It Up. This is what will allow us to run MIU commands from other tools.

Get the Command List

The MIU API is used by making HTTP REST calls to local URL. Every command has a unique identifier which is used to access it. This allows you to rename a command without changing how it’s accessed.

You can open the commands URL in a browser but it’s really messy. Instead, you can download it and examine the file with a JSON editor. Because I’m a Linux guy, I fired up Ubuntu in the WSL to use the handy tools available there.

The first step, is to download the command list. You need to re-download it everytime you add or remove commands to have the most up-to-date command list.

curl http://localhost:8911/api/commands > miu-commands.json

Get the UUID for a Specific Command

Next we have to get the UUID for the command we want to run. In this example, I’m getting the UUID for a command named scene: brb. I use jq in Ubuntu (WSL2) to find the command. You can also upload miu-commands.json to a site like jsonformatter.org instead.

jq '.[] | select (.Name == "scene: brb") ' miu-commands.json

This will spit out a nicely formated JSON segment. The UUID is the ugly 16 character string in the ID field.

{
  "ID": "c3173f6c-13e5-4b6a-92c3-95124f9af667",
  "Name": "scene: brb",
  "IsEnabled": true,
  "Category": "ActionGroup",
  "GroupName": "scenes"
}

That ID is added to the commands URL and looks something like this: http://localhost:8911/api/commands/c3173f6c-13e5-4b6a-92c3-95124f9af667.

To run the command, one needs to sent an HTTP POST request to that URL with an optional JSON document that contains the arguments. If that last sentence didn’t make a lot of sense to you, don’t worry. I’ll walk you through it.

Touch Portal

Touch Portal is a very nice app that has a lot of great features. It’s very easy to use and is free with two pages of buttons. If you need more than that, you can pay for the “Pro” version which gives you unlimited pages and a number of other nifty features.

The Action

Touch Portal has HTTP POST support built in. Edit your button and add an “Http Post” action. Put the URL for the MIU command in the “POST Url” box at the top of the window.

HTTP Post action without arguments

It’s possible to pass arguments to the command but it’s slightly more complicated. First, you need to set the “Content-Type header” to application/json. That tells Touch Portal to let MIU know that it’s going to be sending JSON-formatted data.

The arguments go in the “Data (Optional)” box. For the technically minded, this is a JSON-formatted list. For a single argument, the data value looks like this: ["arg1"]. If you want to pass multiple arguments, the “Data (Optional)” field would look like this: ["arg1","arg2"].

The example below shows a command that I have to change the color of my overlays. I pass the color I want to the MIU command as an argument, in this case, blue.

HTTP Post action with one arguments

Click the “Add” button when you’re done and save your touch button.<

Up Deck

Up Deck is a powerful, free tool designed to run on tablets though it can run on phones. I used Up Deck for a while before I switched to Touch Portal.

The Command

PowerShell has some great tools built-in to make POST requests to the API URL. The first thing that we need to do is create a small wrapper to make the REST calls. Note: This script doesn’t have a way to pass arguments to the commands.

param(
    [Parameter(Mandatory=$true)]
    [string]$id,
    [string]$api_url="http://localhost:8911/api/"
    )

$url="$api_url/commands/$id"
Invoke-WebRequest -uri $url -Method POST

Save the file as run-miu-command.ps1.

The cmdlet is really easy to use by hand.

.\run-miu-command.ps1` -id "uuid"

Unfortunately, that doesn’t work well from Up Deck because it doesn’t handle arguments well. To get around that, you have to create batch files for each command. The batch files are all the same except for the ID. Put them in the same directory as the .ps1 file above.

rem
powershell.exe -NoLogo -NonInteractive -WindowStyle Hidden -executionpolicy bypass -File "%~dp0/run-miu-command.ps1" -id "c3173f6c-13e5-4b6a-92c3-95124f9af667"

When you run this from the command line, it will run the MIU command with the give ID. Unfortunately, the flag -WindowStyle Hidden causes problems for Up Deck. The LOVE console is closed prematurely and that prevents UpDeck from closing cleanly. If you try to restart Up Deck, the leaves the main process hanging around listening on the network ports. Future connections then fail. The only fix, at that point, is to log out or reboot. Fortunately, Up Deck handles hiding the window for you so it’s not needed. The fixed batch file looks like this.

rem
powershell.exe -NoLogo -NonInteractive -executionpolicy bypass -File "%~dp0/run-miu-command.ps1" -id "c3173f6c-13e5-4b6a-92c3-95124f9af667"

That funky %~dp0% in the batch file is replaced with the path that contains the .bat file.

You can run those commands from any tool that lets you run commands.

Up Deck Command

Once you have a batch file for your command, you can create a button that run it. In this example the files are stored in C:\Users\you\Documents. Be sure to change the path to the batch file in the command to match your environment.

scene: brb
launch
app=C:\Users\you\Documents\scene-brb.bat

Update your deck and you should be able to press the button and trigger your MIU command.

One might be wondering, “Why didn’t you use the openurl action? Why bother with all of this PowerShell nonsense?” The openurl action would have been a lot simpler. However, it only supports HTTP GET requests and the Mix It Up API requires one to use POST requests to run commands.