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."