Why isn’t the regex entity being recognized during slot-filling in Copilot Studio, even though it works in CLU testing? And what’s the correct configuration to make it work seamlessly?

Pavithra N 0 Reputation points
2025-05-30T10:57:13.7433333+00:00

I'm using a Azure CLU project integrated with Microsoft Copilot Studio to capture a 6-digit account number using a custom regex entity. Here's the setup:

I defined a regex entity called AccountNumber with the pattern [0-9]{6}.

The utterances are labeled correctly in CLU, such as: "my account number ending with 123456" — with 123456 tagged as AccountNumber.

I registered this CLU entity in Copilot Studio and used it in a Question node as an ExternalEntityReference (code editor)

The intent and entity are detected correctly in CLU testing.

But when I test the bot inside Copilot Studio with: my account number is ending with 123456, the slot-filling still prompts the question again, as if the entity wasn't found in the user input.

If anyone knows the configuration of this CLU and Copilot studio, kindly help me to achieve this scenario

Microsoft Copilot Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ayush Giri 245 Reputation points Microsoft External Staff
    2025-06-02T03:30:13.13+00:00

    Hello Pavithra,

    1. Why the regex entity isn't recognized during slot-filling in Copilot Studio Even though CLU correctly detects the entity (AccountNumber) in its own test environment, Copilot Studio does not automatically use or trust regex-based custom entities for slot-filling. Specifically:
      • ExternalEntityReference in Copilot Studio relies on prebuilt or ML entities, not pure regex.
      • Slot-filling fails when the entity isn’t detected with a confidence threshold or isn't passed back in the RecognizerResult Copilot Studio expects.
      Correct Configuration to Make It Work
      1. In CLU Project:
        • Ensure the AccountNumber entity is explicitly labeled in utterances and tied to the intent used by Copilot Studio.
      2. In Copilot Studio (code editor):
        • In the Question node, do not just use ExternalEntityReference.
        • Add manual validation logic via condition nodes or post-processing using dialog.variable to:
        • Extract a 6-digit number using regex (e.g., dialog.input.match(/\b\d{6}\b/))
        • Then assign it to the correct variable.
      3. Alternative workaround (recommended):
        • Use a Question node with text input and apply a custom validation expression in the UI:
        • Under “Validate user response,” add regex: ^\d{6}$
        • Set error message: “Please enter a 6-digit account number.”
      This skips CLU entirely and enforces format in Copilot Studio directly—far more reliable for regex-based values like IDs, numbers, etc.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.