Skip to main content

What are Procedures?

Procedures are document-style workflows that guide your AI agent through structured processes. They support conditional logic, data fetching, and escalations.

Procedure Syntax

Procedures use special syntax markers embedded in natural language:

Actions: {{action:action_name}}

Call a data connector to fetch data from external systems:
1. Ask the customer for their order number
2. Fetch order details using {{action:get_order_details}}
3. Tell them their order status

Conditions: {{if:condition}} ... {{else}} ... {{endif}}

Add branching logic based on data:
{{if:order_status == "shipped"}}
Your order has been shipped! Tracking: {{tracking_number}}
{{else}}
Your order is still being processed. Expected: {{estimated_ship_date}}
{{endif}}

Escalations: {{escalate:escalation_path_id}}

Escalate to human support:
If the customer needs more help:
{{escalate:escal_path_support}}
I've connected you with a human agent.

Complete Example

# Order Status Check

1. Ask the customer for their order number
2. Fetch order details using {{action:get_order_details}}
3. Check the order status:
   {{if:order_status == "shipped"}}
   - Your order has been shipped!
   - Tracking number: {{tracking_number}}
   - Expected delivery: {{delivery_date}}
   {{else}}
   - Your order is still being processed
   - Current status: {{order_status}}
   - Estimated shipping: {{estimated_ship_date}}
   {{endif}}

4. If the customer needs more help:
   {{escalate:escal_path_support}}
   I've connected you with our support team.

Creating Procedures

Step 1: Create Agent Actions

First, create the actions your procedure will use:
  1. Navigate to AgentsYour AgentActions
  2. Click “Create Action”
  3. Configure the action:
    • Name: get_order_details
    • Description: Fetch order details from API
    • HTTP Method: GET
    • URL: https://api.example.com/orders/{{order_number}}
  4. Click “Save”

Step 2: Create Escalation Paths

Create escalation paths for human handoff:
  1. Navigate to AgentsYour AgentEscalations
  2. Click “Create Escalation Path”
  3. Configure the escalation:
    • Name: Support Team
    • Platform: Slack
    • Destination: #support-channel
  4. Click “Save”

Step 3: Create Procedure

  1. Navigate to AgentsYour AgentProcedures
  2. Click “Create Procedure”
  3. Configure the procedure:
    • Title: Order Status Check
    • Content: Write your procedure using the syntax described above
  4. Enable the procedure
  5. Click “Save”

How Procedures Execute

  1. Document is parsed for syntax markers
  2. Actions execute and results are stored in context
  3. Conditions evaluate using context data
  4. Appropriate blocks execute based on conditions
  5. Escalations trigger when needed
  6. Processed document is provided to AI agent
  7. AI agent responds using the enhanced context

Context Variables

After actions execute, data is available in context:
  • {{action:get_order_details}} → stored in @context['get_order_details']
  • Access nested fields: order.status, customer.email
  • Use in conditions: {{if:order.status == "shipped"}}

Condition Syntax

Comparison Operators

  • == - Equal to
  • != - Not equal to
  • > - Greater than
  • < - Less than
  • >= - Greater than or equal
  • <= - Less than or equal

Examples

{{if:amount > 100}}
{{if:status == "active"}}
{{if:order.total >= 50}}

Best Practices

  1. Test actions first: Ensure actions work before using in procedures
  2. Use clear condition expressions: Keep conditions simple and readable
  3. Handle errors gracefully: Actions may fail - design procedures accordingly
  4. Test escalation paths: Ensure escalation paths are configured
  5. Use descriptive variable names: Makes conditions easier to understand

Troubleshooting

Action not executing

  • Verify action name matches exactly
  • Check action is enabled
  • Review action configuration (URL, method)
  • Check Rails logs for errors

Condition not working

  • Verify variable exists in context
  • Check condition syntax
  • Test condition expression separately
  • Review context data structure

Escalation not triggering

  • Verify escalation path ID is correct
  • Check escalation path is active
  • Ensure escalation path belongs to agent
  • Review escalation service logs

Next Steps

Procedures Example

See a complete procedure execution example

Workflows

Build automation workflows