Skip to main content

Use code phrases and critical steps to trigger tools

Updated this week

Code phrases are verbatim strings that the AI Employee must say during a conversation to trigger backend tool execution. This article explains how critical steps and code phrases work together inside scenarios, walks through practical examples for each tool type, and provides best practices for writing reliable critical steps.

What code phrases are

A code phrase is a specific sentence embedded in a scenario step. When the AI Employee says the phrase during a conversation, the NAF tool detection system analyzes the message and executes the matching backend action (booking, SMS, call transfer, and so on).

Without the exact phrase β€” or the required keywords β€” the tool does not fire, even if the AI Employee says something similar. For example, saying "Hold on, your link will be ready in just a bit" does not send an SMS, because the phrase lacks the keyword "SMS."

There are two patterns:

  • Fixed phrases: The AI Employee must say the sentence verbatim. Example: "I'm submitting your booking right now. Please give me a moment, and I'll get back to you shortly."

  • Keyword-based phrases: The AI Employee's message must contain one or more specific keywords. The exact wording can vary as long as the keywords appear. Example: any phrase containing "SMS" or "text message" triggers the SMS tool.

For the complete list of phrases and their matching operations, see the reference table in Issues with code-phrases (action triggers).

What critical steps are

A critical step is a scenario step marked with **CRITICAL STEP!!!** that contains a mandatory code phrase. The marker flags to both the AI Employee and human editors that exact phrasing is required at that point in the conversation.

The format is:

### **Step X.Y:** **CRITICAL STEP!!!** Say the special **code-phrase**: **"[phrase]"**

For example:

### **Step 1.4:** **CRITICAL STEP!!!** Say the special **code-phrase**: **"Give me a moment to check available slots right now. I'll get back to you shortly."** This is a required phrase β€” without it, you won't be able to check available slots, so it is critical to say this at this step.

Regular scenario steps describe conversational actions (asking questions, confirming information, transitioning to another scenario) and do not require verbatim phrasing. Critical steps are different β€” the AI Employee must produce the exact code phrase or include the required keywords for the backend action to execute.

For general step formatting rules, see Scenario formatting.

How the mechanism works

After each conversational turn the system follows this sequence:

  1. The AI Employee reaches a critical step in the scenario.

  2. The AI Employee says the code phrase to the user.

  3. The NAF tool detection system examines the AI Employee's latest message.

  4. The system evaluates all tool conditions against the message. If every condition for a tool is satisfied, the tool is selected.

  5. The tool executes the backend action (checking availability, creating a booking, sending an SMS, transferring a call, and so on).

  6. The system returns the result to the AI Employee's context.

  7. The AI Employee reads the result and continues the scenario.

πŸ—’οΈ NOTE

The tool detection system uses an LLM to evaluate conditions β€” it is not simple string matching. Code phrases are designed so that their wording clearly satisfies the tool's condition descriptions. This is why even small changes to the phrasing can prevent the tool from firing.

Tool-calling examples

Example 1: Check availability

Tool: check_availability_tool

Context: A restaurant reservation scenario. The AI Employee has gathered the preferred date, time, and number of guests. Now it needs to search for open slots.

Critical step in the scenario:

### **Step 1.4:** **CRITICAL STEP!!!** Say the special **code-phrase**: **"Give me a moment to check available slots right now. I'll get back to you shortly."** This is a required phrase β€” without it, you won't be able to check available slots, so it is critical to say this at this step.

What the AI Employee says:

"Give me a moment to check available slots right now. I'll get back to you shortly."

What happens behind the scenes:

  1. The tool detection system sees the phrase "check available slots" in the latest message.

  2. The agentPromised condition for check_availability_tool is satisfied.

  3. The tool queries the booking system for open slots matching the requested date, time, and party size.

  4. Available slots appear in the AI Employee's context inside the <AvailabilityForTheUserRequestedDateTime> section.

What happens next: The AI Employee presents the available options to the user and asks which one works best.

Example 2: Create a booking

Tool: create_booking_tool

Context: Continuing from Example 1. The user selected a slot and confirmed their name and phone number. The AI Employee asked "Can I submit the booking now?" and the user agreed.

Critical step in the scenario:

### **Step 1.8:** **CRITICAL STEP!!!** Submitting the booking. Say the special **code-phrase**: **"I'm submitting your booking right now. Please give me a moment, and I'll get back to you shortly."** This is a required phrase β€” without it, the booking will not go through, so you must say it at this step.

What the AI Employee says:

"I'm submitting your booking right now. Please give me a moment, and I'll get back to you shortly."

What happens behind the scenes:

  1. The tool detection system sees that the AI Employee is "submitting a booking right now."

  2. The agentPromised condition for create_booking_tool is satisfied.

  3. The tool creates the reservation in the booking system.

  4. A confirmation (or error) appears in the AI Employee's context inside the <ActionsStates> section.

What happens next: The AI Employee confirms the booking to the user or, if there was an error, apologizes and directs the user to the company's website.

❗❗ IMPORTANT

The AI Employee must remain on the critical step until the system response arrives. Moving ahead before receiving a confirmation can cause the AI Employee to tell the user the booking succeeded when it has not been processed yet.

Example 3: Send an SMS

Tool: send_sms_tool

Context: A sales scenario. The AI Employee needs to send the user an SMS with a product link.

Critical step in the scenario:

### **Step 5.3:** **CRITICAL STEP!!!** Share the product link. Say the **code-phrase**: "Give me a moment, I will send you an SMS message with the link [specify what the link contains]. I'll stay on the line and assist you with the next steps. Please confirm receipt of the link."

What the AI Employee says:

"Give me a moment, I will send you an SMS message with the product link. I'll stay on the line and assist you with the next steps. Please confirm receipt of the link."

What happens behind the scenes:

  1. The tool detection system finds the keyword "SMS" in the latest message.

  2. The agentPromised condition for send_sms_tool is satisfied.

  3. The tool sends the SMS to the user's phone number.

What happens next: The AI Employee waits for the user to confirm they received the SMS.

πŸ—’οΈ NOTE

send_sms_tool is keyword-based. The exact wording can vary as long as the message contains "SMS" or "text message." For example, "I will send you a text message with the details" also triggers the tool.

Example 4: Transfer a call

Tool: transfer_call_tool

Context: The user has asked to speak with a human manager. The AI Employee determines a transfer is appropriate.

Critical step in the scenario:

### **Step 4.2:** **CRITICAL STEP!!!** Say the special **code-phrase**: **"I'll connect you right away. Please hold on for a moment."**

What the AI Employee says:

"I'll connect you right away. Please hold on for a moment."

What happens behind the scenes:

  1. The tool detection system finds the keyword "connect" in the latest message.

  2. The agentPromised condition for transfer_call_tool is satisfied.

  3. The tool initiates a SIP transfer to the configured human representative.

What happens next: The call is transferred. The AI Employee's part of the conversation ends.

❗❗ IMPORTANT

transfer_call_tool is only available on the phone channel. It does not activate in chat or other channels.

Best practices

  • Always include the **CRITICAL STEP!!!** marker before any step that contains a code phrase. This signals to both the AI Employee and scenario editors that the phrasing must not be changed.

  • Bold the code-phrase label and the phrase itself: Say the special **code-phrase**: **"[phrase]"**.

  • Explain the consequence of omitting the phrase. For example: "This is a required phrase β€” without it, the booking will not go through, so you must say it at this step."

  • For keyword-based tools, ensure the keyword appears in the AI Employee's quoted speech. The keyword must be in the text the AI Employee actually says, not just in the step instruction.

  • Never remove or rephrase code phrases when customizing scenarios. Rewording a code phrase is the most common cause of tools not firing.

  • Instruct the AI Employee to remain on the critical step until a system response arrives. Add a line such as: "You must remain on this step until you receive the result."

  • Place critical steps after all required information has been gathered and before the AI Employee needs the tool's output. For example, collect the date, time, and party size first, then check availability.

❗❗ IMPORTANT

If a tool is not firing as expected, see Issues with code-phrases (action triggers) for diagnosis steps and the full code-phrase reference table.

Did this answer your question?