Fields as Context

Use fields as placeholders in user prompts.

Context is key to a good user prompt. The more context you can provide, the better the AI can understand the user's intent.

Placeholders in User Prompts

Kirby Copilot provides all fields from the same Kirby model as placeholders in user prompts. This allows you to include additional information in the prompt. To use a field name as a placeholder, wrap it in curly braces: {field}. Placeholders are replaced with the actual field values when the user submits the prompt.

If the field value is not a primitive (e.g. a string, number, or boolean), it will be encoded as JSON before being used as a placeholder. AI models are pretty good at understanding structured data, such as JSON.

Before the user prompt above is sent to the AI model, the placeholder {content} is replaced with the actual field value of the main content.

Whether you use the Copilot Panel view button, the tooltip buttons or the Copilot section, the placeholders are available in every user prompt.

Examples

One common use case is generating text for a specific field, such as a meta description from a page's title and main content. For instance, if your Kirby model has a content field, you can create a user prompt that references this field to generate a meta description:

Write an engaging SEO meta description for the article "{title}". Limit it to 140 characters.

This is my article:
{content}

With Panel View Button

The Copilot Panel view button is the easiest way to generate text for a specific field. Click on the Copilot button in the Panel view header to open the prompt dialog. The user can then select the meta description field from the dropdown menu and enter the prompt above:

Kirby Copilot prompt dialog

With Writer/Textarea Button

If the meta description field is a writer or textarea field, you can also use the Copilot toolbar button in the field toolbar for quick access to the Copilot prompt dialog.

Suppose your page contains a blocks or writer field with the main content and a textarea field for the meta description:

pages/default.yml
fields:
  content:
    label: Content
    type: writer

  metaDescription:
    label: Meta Description
    type: textarea
    buttons:
      # Only allow the copilot button for this field
      - copilot

In this blueprint example, the only visible button for the textarea field is the Copilot toolbar button. This will suggest the user to use Kirby Copilot for meta description generation:

Copilot button in textarea field for SEO description

When the user clicks the Copilot button, the prompt dialog opens. The user can then enter the above prompt, and the placeholder {content} will be replaced with the actual content of the writer field when the prompt is sent to the AI model.

Kirby Copilot textarea prompt dialog

With Copilot Section

Placeholders are also available in the Copilot Panel section. You could set up a Copilot section for the meta description field with a predefined user prompt for a smooth workflow.