I don’t think shortcuts can do that as it would be like an auto routine/process running in the background, constantly checking your messages for the specified string. If it can be done then there may be one of two ways (that I can think of)
one would be to run the custom response shortcut you created but adjust the following: 1: in the IF command you would need to add a repeat or repeat with each command, 2: repeat the run another shortcut command (which you need to create) that checks the messages for the identified filter text string. 3: add the wait for return command so the original shortcut waits to continue for the 2nd shortcut’s results. The shortcut would need to be created in such a way that it’s results are either a yes or no, and the if command will go off of that. If the result is yes (matches string) then continue to send the custom sms. If the result is no then the otherwise function will need to wait (set it to a decent time, maybe 1 minute) and then repeat the checking of the messages like above.
The other option would be to use another shortcut workflow service like iftt or Microsoft flows, that can continuously update a file with message details whenever a new message is received on your iCloud/Apple account, saving the file on your iCloud Drive. Then in the other shortcut you created for the custom sms, you can add a command that checks the worksheet file for the specified text string on repeat until the text is matched, then it will send your sms.