Skip to content

Templates Functions Guide

Template functions enable you to add dynamic functionality within Text Messages in Studio, automated responses, Base Prompts, and Restriction Texts by using default variables and helper methods


Available Variables

YourGPT provides several default variables you can use in your templates to personalize responses:

  • FLOW.last_response
  • FLOW.last_utterance
  • FLOW.{variable_of_your_choice}

Available Functions

YourGPT provides several default functions that can be used in templates to enhance functionality and customize responses:

  • eq(a, b) - Returns true if a equals b.
  • gt(a, b) - Returns true if a is greater than b.
  • lt(a, b) - Returns true if a is less than b.
  • and(...args) - Returns true if all arguments are truthy.
  • or(...args) - Returns true if at least one argument is truthy.
  • not(value) - Returns the negation of the provided value.
  • uppercase(str) - Converts a string to uppercase.
  • lowercase(str) - Converts a string to lowercase.
  • trim(str) - Removes whitespace from both ends of a string.
  • concat(...args) - Joins multiple strings into one.
  • isset(value) - Returns true if the value is not undefined or null.
  • includes(data, searchValue) - Checks if data contains searchValue (works with strings, arrays, and objects).
  • date(date, format, timezone) - Formats a date according to the given format and timezone.
  • day(date, timezone) - Returns the day of the week for a given date.
  • json stringify(context) - Converts a context object into a JSON string.

How to Setup

  • Base Prompt:
Template Functions Inside Studio
  • Inside Chatbot Studio:
Template Functions Inside Studio
  • Using With Automated Response

Working with Date Formats

  • Short Date: {{date format="MM/DD/YYYY"}}12/19/2024
  • Long Date: {{date format="MMMM Do, YYYY"}}December 19th, 2024
  • Day Only: {{date format="dddd"}}Thursday

✅ What to Do

  • Use correct tags like {{/if}}.
  • Check if the variable exists in your data.
  • Verify spelling and case (uppercase/lowercase matters).

❌ What to Avoid

  • Don’t leave tags incomplete; it will break the template.
  • Don’t use curly quotes (“”); always use straight quotes (").
  • Don’t ignore typos—they are a common cause of errors.
  • Don’t add spaces in conditions where they don’t belong.