> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Merlin AI Segment Assist

> Create audience segments by typing plain-English prompts. Merlin AI Segment Assist maps your request to the right events and attribute filters.

<Note>
  This is an Early Access feature. To enable it for your account, contact your CSM or [raise a support ticket](/user-guide/contact-support/contact-support/raise-a-support-ticket-through-moengage-dashboard).
</Note>

# Introduction

Merlin AI Segment Assist allows you to create segments easily by entering prompts in simple English. Finding the right events and the right combination of filters to create a segment is no longer your effort. Merlin AI Segment Assist crafts the most suitable segments based on your prompt, which can be edited right before segment creation.

Merlin AI Segment Assist operates at two levels:

* **Create the query structure**: With GPT 3.5 capabilities, Merlin AI Segment Assist can accurately analyze the structure of the MoEngage query language.
* **Map relevant user and event attributes**: With Retrieval-Augmented Generation (RAG), Merlin AI Segment Assist efficiently bridges natural language inputs with corresponding event or user attributes for a particular workspace.

# Segmentation with Merlin AI Segment Assist

Perform the following actions to use Merlin AI Segment Assist to simplify your segment creation process:

* [Create a segment with Merlin AI Segment Assist](/user-guide/ai-and-intelligence/merlin-ai/merlin-ai-segment-assist#create-a-segment)
* [Optimize your AI-generated queries](/user-guide/ai-and-intelligence/merlin-ai/merlin-ai-segment-assist#optimize-your-ai-generated-queries)

## Create a Segment

Perform the following steps to create a segment with Merlin AI:

1. On the sidebar menu in MoEngage, hover over the **Segment** menu item <img alt="Screenshot 2025-06-16 at 3.25.14 PM.png" src="https://mintcdn.com/moengage/7H2dU4CG2W0DQCPI/images/moengage_70a5b5.png?fit=max&auto=format&n=7H2dU4CG2W0DQCPI&q=85&s=e7babfd39d55594fe84fc743773fbd18" width="74" height="70" data-path="images/moengage_70a5b5.png" />  . The **Segment** menu appears.
2. Click **+ New Segment**.
   <img src="https://mintcdn.com/moengage/CaPmX0z_ys8cr0ms/images/moengage_03ac19.png?fit=max&auto=format&n=CaPmX0z_ys8cr0ms&q=85&s=7c655c4b6dac7996629bedef27b3d134" alt="Screenshot 2025-06-13 at 2.52.15 PM.png" width="546" height="392" data-path="images/moengage_03ac19.png" />
   The **Create Segment** page appears.
3. Click **Use Merlin AI to create segments**. You can switch back to the filter view by clicking **Go to Filter view** to manually generate a query.
4. In the **Type to create a segment** section, enter your prompt. For more information, refer to the [Guidelines to Write Effective Prompts](/user-guide/ai-and-intelligence/merlin-ai/merlin-ai-segment-assist). <img alt="ScreenRecording2025-03-18at2.18.43PM-ezgif.com-video-to-gif-converter.gif" src="https://mintcdn.com/moengage/-6I69HDJzlzOqYai/images/moengage_98b92c.png?s=20f6dcfe7f3394ca05bcd6a410753a6a" width="800" height="445" data-path="images/moengage_98b92c.png" />
5. Click this <img src="https://mintcdn.com/moengage/0iWkm50wROjmHH3Z/images/moengage_d0f41c.png?fit=max&auto=format&n=0iWkm50wROjmHH3Z&q=85&s=2e93f57b30dcd7a9624f89752e3184fa" width="88" height="76" data-path="images/moengage_d0f41c.png" />icon to generate a query. The results of your queries generated with AI will be listed on the **MerlinAI** tab in the **Query results** section.\
   A few sample prompts are listed under the **Prompts to Get You Started** section for your reference.
   <img src="https://mintcdn.com/moengage/4hNKOAjPrnhpJB2_/images/moengage_7cd969.png?s=e395b212f969bdded2669e782001eca3" alt="ScreenRecording2025-03-18at2.24.54PM-ezgif.com-video-to-gif-converter.gif" width="800" height="445" data-path="images/moengage_7cd969.png" />
   1. To find more prompts, click **Explore more prompts**.
   2. You can edit the prompts as required after selecting the sample prompts.
6. To create a segment with the generated query, click **Create custom segment**.
   <img src="https://mintcdn.com/moengage/xeb_76Bworf1GG6P/images/moengage_980954.png?s=24dc68354f78fe0221c9aacb7a876747" alt="ScreenRecording2025-03-18at2.28.51PM-ezgif.com-video-to-gif-converter.gif" width="800" height="446" data-path="images/moengage_980954.png" />
7. In the **MerlinAI** tab of the **Query results** action, you can provide your feedback using the thumbs-up and thumbs-down options below each query.
   1. When you click the thumbs-down option, the Feedback dialogue box will appear.
   2. Enter the prompt you are looking for and click **Submit**.
      <img src="https://mintcdn.com/moengage/wIFGWsQFEjsz2j4v/images/moengage_e2c599.png?fit=max&auto=format&n=wIFGWsQFEjsz2j4v&q=85&s=2b9613602f37602479baf77afcbb9b25" alt="" width="806" height="594" data-path="images/moengage_e2c599.png" />
      Your feedback helps MoEngage provide better query results that are suitable for your prompt through AI.

## Optimize Your AI-Generated Queries

You can optimize your Merlin AI-generated queries by regenerating them, which provides new query results with different filters for the same prompt.

After the query is generated, check the filter condition described under **Showing users for**. If the filters do not match your requirements, click **Regenerate**. Merlin AI will generate a new query with different filters. On regeneration, Merlin AI tries to map the next nearest event or user attribute as per your prompt.

<img src="https://mintcdn.com/moengage/QVZKszouQuxXOzFr/images/moengage_1e0a2c.png?s=7a6364c109ded5a979b73ed8f02a9adc" alt="ScreenRecording2025-03-18at3.28.24PM-ezgif.com-video-to-gif-converter (1).gif" width="800" height="455" data-path="images/moengage_1e0a2c.png" />

### Optimize the Query in Filter View

The filter view opens your queries with filters, which allows you to add additional filters (such as nested filters and affinity queries) to your Merlin AI-generated query.

* Click **Open in filter** **view** to edit queries using filters manually. This result will be listed under the **Filters** tab in the **Query Results** section. For more information on creating segments manually, click [here](/user-guide/segment/segment-operations/create-segments).
* Once the query is generated, you can create segments or campaigns by clicking **+ Action**.\\
  <img src="https://mintcdn.com/moengage/2kQqTYC5RUPSd8kI/images/moengage_3eef65.png?s=e267ab902ecbc5f3d232ee16b119ab97" alt="ScreenRecording2025-03-18at2.39.42PM-ezgif.com-video-to-gif-converter.gif" width="800" height="446" data-path="images/moengage_3eef65.png" />

# Guidelines to Write Effective Prompts

The guidelines and prompt structures to write effective prompts are discussed below:

<Info>
  * Refer to the [key concepts](/user-guide/segment/basics-of-segmentation/basics-of-segmentation) of segmentation at MoEngage before using a query with Merlin AI Segment Assist.
  * User attributes and user activity (events and event attributes) are the building blocks of segmentation.
  * Filters are used to filter specific user attributes and events.
  * Operators (AND/OR) are used to combine multiple segment blocks.
</Info>

## Prompt Structures

The following are the best prompt structures with examples:

* You must query events (user behavior) and user attributes (user property) with different prompts to generate the most accurate filters.
  * Apply the following structure for querying user attributes:\
    Segment users whose city/country/email ID/mobile number, etc, is `<value>`. For example, Segment users who are in New York City.
  * Apply the following structure for querying events:\
    Segment users who have done/performed an `<event>` in the last n days. For example, Segment users who opened the app in the last 7 days.
  * Apply the following structure for querying events with event attributes:\
    Segment users who have done/performed a `<event>` with `<event attribute>` containing `<value>`. For example, segment users who have updated the app in the last 15 days with app versions containing 2.3.
  * Apply the following structure for querying users who have not performed a certain event:\
    Segment users who have not done/performed a `<event>` with `<event attribute>` containing `<value>`. For example, segment users who have not updated the app in the last 15 days.
* Joining queries with AND/OR
  * You can combine user attributes and events using an AND or OR as required by your business logic.
  * Apply the following structure for queries combining user attributes and events in the following order: user attributes first, followed by events.
    * Segment users whose `<user attribute>` is `<value>` and who have done an `<event>` in the last few days. For example, segment users who are in New York City and have opened the app in the last 30 days.

## Sample Prompts to Get You Started

For a better understanding of prompt structure and usage, some of the sample prompts are listed as follows:

* **7-day active users**: Segment users who opened the app in the last 7 days.
* **Users from a city**: Segment users who are in New York City.
* **Perform an action**: Segment users who opened an email last week.
* **Number of actions**: Segment users who have clicked a push notification at least 5 times in the last 30 days.
* **Joint conditions**: Segment users who are in New York City and who have opened the app in the last 30 days.
* **Did not perform an action**: Segment users who have not updated the app in the last 15 days.
* **Channel Interactions**: Segment users who have clicked a notification from an Android device at least once in the last 3 days.
* **For the first time**: Segment users who have opened the app for the first time in the last 30 days.
* **Data validation**: Segment users whose email IDs are not available.
* **Starts with**: Segment users whose mobile number starts with +91.
* **Ends with**: Segment users whose email ID ends with education.
* **Contains a substring**: Segment users whose email ID contains @moengage.
* **Contains multiple substrings**: Segment users whose email ID contains @moengage, @gmail, @hotmail.
* **Numerical actions**: Segment users who opened the app in the last 3 days with an app version greater than 16.1.

<Info>
  - Merlin AI Segment Assist currently does not support nested filters, affinity queries, and custom segments.
  - Merlin AI Segment Assist can access any blacklisted attribute in the data management for 1 day from the day of blacklisting. These attributes are not included in your results from the next day. Please check your results before proceeding further.
</Info>
