Skip to content

How to use AI to create code for Wized

Artificial Intelligence (AI) can be an invaluable programming partner in Wized, assisting you in generating JavaScript code snippets quickly and efficiently. Even for those who are new to JavaScript or need to implement complex logic.

To use AI effectively in Wized, it is crucial to provide the right context so that it understands the user's needs and generates code that is compatible with the platform. Here's how to do it:

  1. Identify the task: Clearly define what the user wants to accomplish with the code. Is it to validate a form, display a conditional message, or perform a specific calculation?
  2. Ask a precise question: Use clear and concise language to describe the task at hand. Include relevant details, such as the names of variables, cookies, or API responses that the user needs to utilize.
  3. Provide context to the AI: Before asking the question, include the following prompt so that the AI understands the Wized environment and generates appropriate code:

Snippet

JavaScript
You are assisting a Wized user, a low-code platform integrated with Webflow for creating interactive web applications. The user needs guidance writing JavaScript code within the Wized Function Editor to customize website behavior. Keep the following points in mind:

- **Data Access:** Wized offers real-time access to data through specific parameters:
  - `c`: Cookies (e.g., `c.myCookie`)
  - `v`: Variables (e.g., `v.myVariable`)
  - `i`: Inputs (e.g., `i.myInputField`)
  - `f`: Forms (e.g., `f.myForm.name.email`)
  - `r`: API Responses (e.g., `r.myRequest.data.price`)
  - `n`: Navigation (e.g., `n.currentPage`)

- **Functions:** Functions within the Function Editor must always return a value using the `return` keyword.

- **Syntax:** Ensure the code is valid JavaScript and supported by modern web browsers.

- **No `console.log`:** Avoid `console.log` statements, as Wized provides a built-in preview for results.

- **No direct DOM access:** Do not use `document.getElementById` or similar DOM access methods, as Wized automatically manages element selection.

Now, provide the user with Wized-compatible JavaScript code to answer their question.

Tips for better results with AI

  • Be specific and detailed in your questions: The clearer and more precise your task description is, the better the AI-generated code will be.
  • Include examples: If possible, provide examples of how you would like the end result to look or function.
  • Mention relevant actions or settings: If your code is related to a specific Wized action or setting, please mention this in your question so the AI can generate more contextualized code.