diff --git a/gstlal-inspiral/bin/Makefile.am b/gstlal-inspiral/bin/Makefile.am
index 7fdc623094f51f8a57d3aa794ca14aefc05bf466..ddd9e5a1b3fac125a81466519f892d845296276b 100644
--- a/gstlal-inspiral/bin/Makefile.am
+++ b/gstlal-inspiral/bin/Makefile.am
@@ -5,6 +5,7 @@ dist_bin_SCRIPTS = \
 	gstlal_iir_inspiral \
 	gstlal_inspiral \
 	gstlal_inspiral_add_mass_models \
+	gstlal_inspiral_add_template_ids \
 	gstlal_inspiral_calc_likelihood \
 	gstlal_inspiral_calc_rank_pdfs \
 	gstlal_inspiral_coinc_extractor \
diff --git a/gstlal-inspiral/bin/gstlal_inspiral_add_template_ids b/gstlal-inspiral/bin/gstlal_inspiral_add_template_ids
new file mode 100755
index 0000000000000000000000000000000000000000..f82ee14aa7449dc999f992a636342de615fbc622
--- /dev/null
+++ b/gstlal-inspiral/bin/gstlal_inspiral_add_template_ids
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2018  Chad Hanna
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+# # This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+### This program inputs a template bank from lalapps_tmpltbank, and returns
+### a template bank with a unique template_id row. Used to overcome the
+### "Asserion Error: assert row.template_id not in ids" error from 
+### gstlal_inspiral_mass_model.
+
+import sys
+from glue.ligolw import ligolw
+from glue.ligolw import lsctables, param as ligolw_param, array as ligolw_array
+from glue.ligolw import utils as ligolw_utils
+
+@ligolw_array.use_in
+@ligolw_param.use_in
+@lsctables.use_in
+class LIGOLWContentHandler(ligolw.LIGOLWContentHandler):
+	pass
+
+fname = sys.argv[1]
+
+xmldoc = ligolw_utils.load_filename(fname, verbose = True, contenthandler = LIGOLWContentHandler)
+sngl_inspiral_table = lsctables.SnglInspiralTable.get_table(xmldoc)
+
+for n, row in enumerate(sngl_inspiral_table):
+	row.template_id = n
+
+ligolw_utils.write_filename(xmldoc, fname, gz = fname.endswith('gz'), verbose = True)
diff --git a/gstlal-inspiral/tests/Makefile.offline_tutorial_test b/gstlal-inspiral/tests/Makefile.offline_tutorial_test
index 1b01e293561ab07ea88740cc02b35bd902d6ddc9..a1bf4ba9bf15ac436e9df10d3645f06534e1f86a 100644
--- a/gstlal-inspiral/tests/Makefile.offline_tutorial_test
+++ b/gstlal-inspiral/tests/Makefile.offline_tutorial_test
@@ -385,6 +385,7 @@ gstlal_bank.xml.gz: frames.cache
 		--spectrum-type median \
 		--write-compress \
 		--verbose
+	gstlal_inspiral_add_template_ids H1-TMPLTBANK-1000000000-2048.xml.gz
 	mv H1-TMPLTBANK-1000000000-2048.xml.gz gstlal_bank.xml.gz
 	@echo ""