Help

User Segmented Prompts

Airgentic Help

User-segmented prompts let you deliver different instructions to your AI agent based on a user's location. When a user asks a question, the system automatically looks up their country, city, or region and injects location-specific content into the prompt — without any code changes or manual routing.


How It Works

  1. Add a segment tag to your agent prompt where you want location-specific content to appear, e.g. {{segment:Country}}.
  2. Create a Segmented Prompt for that location (see "Creating a Segmented Prompt" below).
  3. When a user from India asks a question, your India-specific content is automatically substituted into the prompt where the tag appears.
  4. If no segmented prompt exists for the user's location, the tag is removed and the prompt continues without it.

Supported Segment Tags

Tag Session Field Description
{{segment:Country}} User's country e.g. India, China, United States
{{segment:City}} User's city e.g. Mumbai, Sydney, London
{{segment:Region}} User's region/state e.g. Western Australia, California

Location is determined automatically from the user's IP address when they connect.


Example Use Case

Suppose you run a university enrolment service and want to show country-specific entry requirements. Your main agent prompt might include:

REGION-SPECIFIC GUIDANCE

{{segment:Country}}

If no country-specific guidance is available, provide general international student information.

Then create Segmented Prompts for the countries you want to target. When a student from India asks about requirements, the agent sees the India-specific content. A student from China sees the China-specific content. A student from France (with no segmented prompt) sees just the fallback text.


Creating a Segmented Prompt

UI Design screen

  1. Go to Edit Prompts
  2. Click Add Prompt
  3. Select Segmented Prompt
  4. Choose the Segment Attribute (Country, City, or Region)
  5. Enter the Segment Value (e.g. "India", "Mumbai", "Western Australia")
  6. Click Create Prompt

The new segmented prompt opens in the editor with a template. Add your location-specific instructions below the template text.

Example: Country India

After creating a segmented prompt for Country = India, you might add content like:

The user is in the Country:India segment. Apply the following relevant instructions for this segment when responding:

For students from India:
- Accepted qualifications: CBSE Class XII, ISC, State Boards
- Minimum marks: 75% in relevant subjects
- English requirement: IELTS 6.5 or equivalent
- Popular pathways: Foundation programs available for students not meeting direct entry

Combining Multiple Tags

You can use multiple segment tags in the same prompt for more granular segmentation:

{{segment:Country}}

{{segment:Region}}

{{segment:City}}

Each tag is resolved independently. If a segmented prompt exists, its content is injected; if not, the tag is silently removed.


Debugging with Trace Log

When testing in Admin Chat, the Trace Log shows which segment substitutions were applied for each request. Look for the Segment prompt substitutions event, which displays the attribute names and values that were matched:

{
  "event": "Segment prompt substitutions",
  "data": {
    "Country": "India",
    "City": "Mumbai"
  }
}

This helps you verify that segmented prompts are being loaded correctly for different user locations.


Performance and Caching

Segmented prompts are cached in memory after the first load, so there is no performance penalty for using them. The cache is automatically cleared when you reload your service configuration, allowing new or updated segmented prompts to take effect immediately.


Best Practices

  • Start with countries — Country-level segmentation covers the most users with the fewest prompts.
  • Use fallback text — Always include fallback instructions in your main prompt for locations without a segmented prompt.
  • Keep segments focused — Each segmented prompt should contain only the location-specific differences, not duplicate shared content.
  • Test with Admin Chat — Use the Trace Log to verify which segments are being loaded for different test scenarios.

← Back to Agents & Prompts overview

You have unsaved changes