Inbox AI
  • Introduction
  • Quick Start
  • Hotkeys / Triggers
  • AI providers
  • Voice Commands
  • Screenshots
  • Watch Directories
  • Email Processing
  • Handle Incoming Calls
  • Actions
    • Custom Actions
      • Ask AI
      • Make API Request
      • Terminal Command
      • Multiple Choice
      • Group
    • Built-in Actions
      • Mail Actions
        • Mark as Read
        • Mark as Unread
        • Set Flag
        • Set Background Color
        • Move to Junk
        • Move to Archive
        • Move to Trash
      • Flow Control
        • Return Result to Previous AI
      • System Actions
        • Copy to Clipboard
        • Get Selected Text
        • Take Screenshot
        • Paste at Cursor
        • Speak Text
        • Send Notification
        • Add Apple Reminder
      • Do Nothing
    • Folder
    • Next Action Field
    • Action Variables
    • Export
  • Templating
  • Transcription
  • Logging
  • Limits
  • Troubleshooting
  • Advanced Settings
  • Integrations
    • AppleScript
    • Tana
    • Apple Notes
    • Reflect
    • Apple Shortcuts
    • Raycast
    • X-Callback-URL
Powered by GitBook
On this page
  • Variables
  • Built-in Variables
  • Filters
  • Built-in Filters
  • Flow Control
  • Defer Replacing Variables

Templating

This page describes the Stencil templating library used by Inbox AI to replace placeholders with actual values in actions. Variables work in most fields in Inbox AI.

PreviousExportNextTranscription

Last updated 6 months ago

Templates use the format, with some extensions. Check the documentation for Stencil for advanced instructions.

Variables

Any of the Action Variables you create (human or ai) can be used inside fields inside Inbox AI using the following format: {{ name }} . This allows you to send things from AI to AI, or use human configuration options.

Built-in Variables

There are a few built in (always available) variables:

  • {{ time.now }} The current time (i.e 14:00:24). Also available are {{ time.hour }}, {{ time.minute }} , and {{ time.second }}

  • {{ date.today }} The current date (i.e 2024-01-01). Also available are {{ date.year }} , {{ date.month }} , {{ date.day }} , and {{ date.weekday }} (ie. Tuesday)

  • {{ originalInput }} The original input of the AI action chain. Usually the email source, OCR text from the screenshot, or transcribed voice command.

  • {{ settings.name }} Your full name, from the settings pane.

  • {{ dir.tmp }} A tmp directory you can write files to, often used in combination with {{ run.id }}

  • {{ run.id }} A unique id for this specific action execution, use {{ originalInput | hash }} for the unique id of the entire action chain.

Filters

Filters can be run on any variable. They change the variable. There are several default filters in Stencil, check their . A very useful example is {{ name | default:"World" }} , which sets the default value for a variable if it is left blank.

Built-in Filters

We have built in several useful filters to use in your templates:

  • {{ originalInput | process }} This filter should only be used with the originalInput variable. It processes the input as an email (or keeps the original if it is not an email). This filter extracts only the Message-ID, From, To, Subject, and Date headers. Additionally, it only returns the plain text body of the email (HTML is the backup) and the names of any attachments. This saves a lot of AI tokens.

  • {{ name | jsonEscape }} This filter escapes standard JSON characters (ie. quotes and newlines) so you can use the variable inside of a JSON structure.

  • {{ name | doubleQuoteEscape }} This filter escapes double quotes so you can use the variable inside of a terminal commands.

  • {{ name | hash }} This creates a unique hash for the content in the variable, useful for output to files.

  • {{ originalInput | match:"Message-ID: (.?)" }} A regex match filter. Applies the given regex, and returns the first capture match. By default it does not cross newlines and is case insensitive. You can change this by giving boolean values as arguments. i.e. {{ originalInput | match:"\n\n(.?)",false,true }} does not cross multiple lines, but is case sensitive.

  • {{ originalInput | extractEntities }} A filter that extracts names, places, and organisations using the Apple linguistic tagger (not super accurate, but still useful)

Flow Control

Defer Replacing Variables

If you need to generate text that has a sensitive values in it, you can use 'double-templating'. By escaping you can defer the replacement until the next action.

i.e. If you send \{\{ password \}\} to the AskAI action, it will not be replaced by the actual password until it reaches the next action, this can often be used to prevent sensitive information has to pass through an AI action.

{{ name | percentEncode }} This filter encodes an URL component for use in a URL string. You can specify the part of the URL (defaults to "query"), like so: {{ name | percentEncode:"host" }} . Options are query, host, user, password, and fragment. See for more info about the parts.

Stencil supports for loops, if-statements, and equality checks too. See their .

Stencil
documentation
this
documentation