The Response Controls tab enables you to regulate agent outputs by defining and managing specific keywords and phrases. These controls ensure appropriate and on-brand interactions while preserving user experience.

Key benefits

  • Enhanced safety: Prevent the agent from generating inappropriate or off-brand responses.
  • Improved brand adherence: Filter out responses that deviate from brand guidelines.
  • Operational efficiency: Configure Response Controls directly in the PolyAI UI without backend modifications.
  • Custom metrics tracking: Monitor and analyze agent behavior for better performance insights.

How it works

Response Controls use string matching and regex patterns to monitor agent responses in real time. When a response matches a predefined stop keyword or phrase, the system can:

  1. Halt the response: Immediately stop response generation.
  2. Log the occurrence: Track matches for analytics and review.

This functionality helps ensure adherence to safety and brand standards without disrupting the flow of conversations.

Getting started

Accessing Response Controls settings

  1. Navigate to Response Controls: Access the settings from the Response controls page.
  2. Create a new phrase:
    • Click Add Phrase to open the creation form.
    • Fill out the required fields:
      • ID: A unique identifier for tracking the stop keyword.
      • Description: (Optional) Describe the purpose of the stop keyword for team understanding.
      • Regular Expression: Enter a regex pattern to define the keyword or phrase.
      • Say Phrases: Toggle to determine whether matching phrases halt the response (TRUE) or are tracked for analytics (FALSE).

Feature details

Response Controls structure

Response Controls are organized as stop keywords, each with specific attributes:

  • ID (String): Unique identifier for tracking and analytics.
  • Description (String): Optional text to clarify the keyword’s purpose.
  • Regular Expression (String): Regex pattern that identifies the phrases or words to control.
  • Say Phrases (Boolean): Specifies whether matching phrases halt responses (TRUE) or are logged for analysis (FALSE).

Stop keywords

Use stop keywords to ensure your agents react quickly and appropriately to sensitive information or inappropriate conversations.

Navigate to the Functions section under the Build tab to define a custom function for handling stop keywords.

Example setup:

  • Name: ashmolean
  • Description: Respond when stop keywords are detected.
  • Type: String
  • Function definition:
def ashmolean(conv: Conversation):
    return "The detected phrase is restricted. Please adjust your input."

Example configuration

ID: stop_inappropriate Description: Prevent responses containing offensive language. Regular Expression: /\b(offensiveWord1|offensiveWord2)\b/i Say Phrases: TRUE

This setup ensures responses containing “offensiveWord1” or “offensiveWord2” are immediately halted.

Advanced configuration

You can use regex to define complex patterns for fine-grained control over responses. For a detailed guide on regex, refer to Regex documentation.

Custom metrics tracking

Response Controls log all occurrences of matches for analytics. You can view these metrics in the Analytics Dashboard to identify trends, evaluate agent behavior, and refine controls over time.

Practical use cases

  • Safety compliance: Prevent offensive or harmful language in user interactions.
  • Brand adherence: Block responses with phrases outside approved messaging.
  • Content moderation: Identify and log responses that require review or adjustment.

Use stop keywords to remove unnecessary preambles

LLMs often add unnecessary meta-explanations before executing an action, which can slow down response times and, more importantly, annoy users. By applying stop keywords, you can ensure that agents immediately proceed with relevant information without unnecessary preamble or repetition.

Example: Before and after applying stop keywords

Without stop keyword:

  • User: “I want to cancel my plan.”
  • Agent: “Let’s start by gathering some information. Please hold on while I check your cancellation options. Here are your cancellation options.”

With stop keyword on “let’s start” applied:

  • User: “I want to cancel my plan.”
  • Agent: “Here are your cancellation options.”

How to implement stop keywords

Add a stop keyword to block redundant transition phrases:

  • ID: flow_redundancy_cutoff
  • Description: Prevents unnecessary filler before a response.
  • Regular Expression: \b(let's start|please hold on|let me check)\b
  • Say Phrases: TRUE (halts response when detected).

Steps to set up:

  1. Go to Response Controls in Agent Studio.
  2. Click Add Phrase and enter:
    • ID: flow_redundancy_cutoff
    • Regular Expression: \b(let's start|please hold on|let me check)\b
    • Say Phrases: TRUE
  3. Save and test the assistant’s responses.

Optional: Redirect to a function for better phrasing

Stop keywords can also trigger a function to replace the blocked phrase with a cleaner response of your choice.

def flow_redundancy_cutoff(conv: Conversation):
    return "Here are your options."

Pronunciations

PolyAI uses Text-to-Speech (TTS) to convert text into spoken language. Occasionally, uncommon words, domain-specific terms, or proper nouns may be mispronounced. In these cases, the TTS Pronunciations tab is available to embed pronunciation guidelines for key phrases in the global rules.

Key points

  • Enhanced pronunciation accuracy: Correctly pronounce domain-specific terms and unique phrases using IPA.
  • Streamlined workflow: Manage rules directly in the agent studio.
  • Flexibility: Adjust pauses and pronunciation for various needs.

Key benefits

  • Improved voice quality: Ensure accurate and natural speech.
  • Domain-specific customization: Adapt to the terminology of your industry, whether medical, legal, hospitality, or another area.
  • Efficient workflow: Eliminate external configuration.
  • Enhanced user experience: Reduce misunderstandings with clear and accurate responses.

How it works

Pronunciations use the International Phonetic Alphabet (IPA) to define pronunciation rules. You can also use SSML (Speech Synthesis Markup Language) such as <break>, <prosody>, and <emphasis> in the replacement string.

You may define pronunciation rules using regular expressions and replacements, including support for regex capture groups.

Using capture groups in replacements

If your regular expression uses capture groups (for example, (\d{3})), you can refer to these in the replacement string using \1, \2, etc. This allows you to reformat matched text dynamically.

Example: Formatting a phone number with pauses

To transform a number like (651) 359-2923 into:

“six five one [pause] three five nine [pause] two nine two three”

Use the following pronunciation rule:

  • Regex: $begin:math:text$?(\\d{3})$end:math:text$?[ -]?(\d{3})[ -]?(\d{4})
  • Replacement: \1 <break time="0.5s" /> \2 <break time="0.5s" /> \3
  • Case sensitive: FALSE

This uses SSML breaks between capture groups, allowing for natural read-back of phone numbers or similar patterns.

Example: IPA correction

  • Regex: /\bLouvre\b/
  • Replacement: /ˈluːvrə/
  • Case sensitive: FALSE

This ensures “Louvre” is pronounced correctly.