The Arcade assistant (beta) uses artificial intelligence (AI) to generate ArcGIS Arcade expressions from instructions typed in natural language.
Arcade can be used to create custom data-driven content in various mapping contexts, such as styling layers, configuring pop-ups, and configuring labels. For example, you can use Arcade to dynamically display new information from existing fields in the layer based on data values and thresholds you define. Similar to other coding languages, writing and diagnosing errors in Arcade expressions can take time. The Arcade assistant (beta) can help improve efficiency of this process by generating an expression or part of an expression without you having to write any code.
Note:
For more information on the assistant, including credit consumption, security and privacy, and limitations and bias, see Arcade assistant (beta).
Use the assistant
The Arcade assistant (beta) uses natural language to generate Arcade code. For best results, use clear and plain language and iterate on the responses you receive.
Note:
The assistant is administered at the ArcGIS Online organization level and may be disabled by your administrator.
To use the assistant, do the following:
- Confirm that you are signed in to an organization.
- Click the app launcher
and select Map Viewer. Use the new map that opens and add a layer to the map or open an existing map.
- Open the attribute expression editor window from the Styles, Pop-ups, or Label features pane.
Note:
For additional information on styling a layer using an expression, see Apply a style. To configure pop-ups using an expression, see Use expressions. To configure labels using an expression, see Apply labels.
- Click Arcade assistant
.
The Arcade assistant pane opens.
- Use the assistant by doing either of the following:
- Click a suggestion and modify it to build a prompt that fits your data.
- In your preferred language, enter a prompt to build an Arcade expression.
- Click Generate to perform your query.
The Arcade assistant (beta) suggests an expression in the Arcade assistant pane.
Tip:
Hover over the Profile context
button to see where the suggested expression will be applied in the layer configuration. Hover over the Layer context
button to see the layer metadata provided to the assistant used for generating the suggested expression.
- To interact with the suggestion, do any of the following:
- Click Add to editor to add the expression to the expression builder pane.
Tip:
Position your cursor in the expression builder pane where you want the content to be added. For example, in the expression builder pane, move your cursor and click in front of an existing line of code. When you click Add to editor in the Arcade assistant pane, the suggested expression will be added to the expression builder pane at the position of the cursor.
- Click Replace all code in editor
to replace any existing content in the expression builder pane with the suggested expression.
- Click Copy code to clipboard
to copy the suggested expression to the clipboard.
- To make adjustments to the prompt, edit the previous prompt in the text area or copy and paste a previous prompt, then click Refine to submit the modified query.
- To provide feedback on the assistant, click the Helpful
or Unhelpful
button and complete the survey. The feedback is used to guide further development.
- Click Add to editor to add the expression to the expression builder pane.
Understand best practices
The following are guidelines that will help you generate Arcade expressions using the Arcade assistant (beta):
- Be clear and concise in your request.
- Avoid ambiguity and vague language.
- While using exact field names is not required, providing sufficient detail is recommended.
Tip:
See the following for an example of a productive prompt versus an unproductive prompt when creating an expression to configure labels:
- Productive prompt: "Label each county with last year's total wheat harvest. If a county didn't produce wheat, don't display a label." This prompt is productive because it is clear, concise, and actionable.
- Unproductive prompt: "Choose a label for the features." This prompt is unproductive because the assistant doesn't choose how to label features. The assistant only generates expressions based on the author's instructions. The map author should decide what features they want labeled and how to label them, then ask the assistant to generate an expression to accomplish their goal.
Context limitations
Keep in mind the following limitations while using the Arcade assistant (beta):
- The assistant is not a chatbot. It does not remember information you provided in previous prompts. When refining a previous prompt, be sure to include all relevant details as if you were asking the assistant for the first time.
Tip:
See the following for an example of a productive sequence of prompts versus an unproductive sequence of prompts:
- Productive sequential prompts:
- “Create an HTML table where each row is a population field.” The assistant generates a table, but without formatting.
- “Create an HTML table where each row is a population field. Format the numbers with commas.” The context of creating an HTML table is retained with the additional detail of asking for field formatting, making this a productive sequence of prompts.
- Unproductive sequential prompts:
- “Create an HTML table where each row is a population field.”
- “Now format the numbers with commas.” The context of creating an HTML table is now missing, making this an unproductive sequence of prompts.
- Productive sequential prompts:
- The assistant is not aware of any previously generated Arcade expressions or of existing expressions in the Arcade editor or web map.
Tip:
See the following for an example of a productive prompt versus an unproductive prompt:
- Productive prompt: “Simplify this expression: <insert expression here>." This prompt is productive because the user has provided enough context for the assistant to be able to generate an expression.
- Unproductive prompt: “Simplify the expression in the editor." This prompt is unproductive because the assistant is unaware of the expression in the editor.
- The assistant does not query your data. For this reason, it is not aware of specific data values present in the layer for which you are generating the expression. If you want the assistant to write conditional logic based on data values, you must provide those in your prompt or allow the large language model to assume the values.
Tip:
See the following for an example of a productive prompt versus an unproductive prompt:
- Productive prompt: "If the score is above 100, return ‘good’. If it is above 75, return ‘moderate’. If it is between 20-75, return ‘bad’. If it is below 20, return ‘horrible’." This prompt is productive because the values are specific and the categories are defined.
- Unproductive prompt: “Break up the score field into multiple categories using natural breaks: ‘good’, ‘moderate’, ‘bad’, ‘horrible’.” This prompt is unproductive because the assistant does not know the range of values to categorize.
- You cannot use the assistant to search, reference, or query other layers in the map. The only context the assistant has is field names and aliases for the layer executing the expression. Additionally, the assistant is unaware of attachments and related tables that may be associated with the layer. For this reason, there is limited support for generating expressions using FeatureSet functions. If accessing data from other layers is desired, you should provide the layer title or item ID for the assistant to know which information to include in the expression. If this information is not provided, the assistant will generate a title or ID that you will need to manually replace when the generated expression is added to the expression builder pane.
Tip:
See the following for an example of a productive prompt versus an unproductive prompt:
- Productive prompt: “Return the number of incidents that occurred within the boundary of Washington state. Use the NAME field in the us_states_2000 layer to perform this calculation." This prompt is productive because it defines the specific geographic boundary and the layer in the map that should be used when generating the expression.
- Unproductive prompt: “Return the number of incidents that occurred in Washington.” This prompt is unproductive because it is unclear whether Washington state or Washington, D.C. is desired. Additionally, it is unclear which layer in the map should be used when performing the query.