Generate expressions

Use SnapGPT to generate expressions to use in Snaps with expression-enabled fields.

SnapGPT can generate or refine expressions for the expression-enabled fields across all Snaps and Accounts. For the Mapper Snap, SnapGPT also uses the input schema from available preview data. Learn more about it from Map to target and Extract pipeline parameters

As an example, this document explains how to use SnapGPT to generate an expression for a File Reader Snap.

In a pipeline that reads files from an S3 bucket or over SFTP, you might want to retrieve them based on the date they were saved. Assume that all the files have the same name with the current date appended to it. To simplify the example, we'll use the File Reader Snap, which reads from the SnapLogic file system.

This example explains how to:
  • Generate an expression using the Expression enabler
  • Generate an expression using SnapGPT
  • Refine an existing expression using SnapGPT

To use the Expression enabler to generate an expression:

  1. In Designer, open the File Reader Snap.
  2. Below the File field, click the Expression enabler icon .
  3. Click the light bulb icon on the right side of the field to view the list of available functions and properties. You can browse or search for a function or use the Expression builder to write an expression.

To use SnapGPT to generate an expression:

  1. Click the SnapGPT icon, , enter a prompt, such as Use a variable for the filename and append the current date, and click the arrow icon, to generate the expressions and choose any one of them. In this example, SnapGPT generates a list of five expressions:

To use SnapGPT to refine an expression:

  1. To refine an existing expression, click the SnapGPT icon, , enter a prompt, such as Append time in the Refine expression field, and click the arrow icon, . In this example, SnapGPT refines the expression and suggests a list of expressions that append time to the file name and current date.