Templater How to prompt for a filename, change the file to the input, and then set text within file to the input

I am trying to make a template that is automatically created when a new file is made in a specific folder. I want it to do these steps:

  1. Prompt the user for a text input
  2. Set the filename to that input
  3. Create a property of “tags” with a tag of “ma222”
  4. Add the input within the file as text

Here is the code that I currently have for the template file:

<%*
  // Prompt for the title
  const title = await tp.user.prompt('Enter title name');
  
  // Rename the file to the entered title
  await tp.file.rename(title);
%>

---
tags: [ma222]
---

<%- title %>

---

Place holder text that will proceed here.

So for example, if I were to input “Test” as the filename, I want it to look like this:

When I created this template, the formatting of the properties section looked abnormal when I turned off source mode, with Obsidian changing the look of the “tags” text to a header 2, and creating a line above the “tags” text (The line above the placeholder text is intended):

When the correct view of the properties section should look like this:

When I attempt to create a file in the designated folder that I set in Templater’s settings, I do not get prompted for the title, and instead, I get a parse error:

plugin:templater-obsidian:6 Templater Error: Template parsing error, aborting. 
 tp.user.prompt is not a function
K	@	plugin:templater-obsidian:6

What I have tried

I tried using tp.prompt instead of tp.user.prompt. It gives the same error. I also tried putting the YAML code of the properties before the javascript code, like this:

---
tags:
  - ma222
---

<%*
  // Prompt for the title
  const title = await tp.user.prompt('Enter title name');
  
  // Rename the file to the entered title
  await tp.file.rename(title);
%>

<%- title %>

---

Place holder text that will proceed here.

When I format the text like this, the properties do display correctly in the template (not when creating files). However, I get the exact same error when I create a new file with this template.

I would appreciate any help with this, as I am very new to using Templater. Thanks!

I have found the solution to this. Instead of using tp.user.prompt, you need to use tp.system.prompt. This is because tp.user.prompt and tp.prompt are only available for user created scripts and NOT embedded scripts within templates, as I was using. The code that I used that made this correct was:

---
tags: [ma222]
---
<%*
  // Prompt for the title
  let title = await tp.system.prompt('Enter title name');
  
  // Rename the file to the entered title
  await tp.file.rename(title);
%>

<%- title %>

---

Place holder text that will proceed here.

The properties also needed to be above the embedded javascript in order to properly display.