> ## Documentation Index
> Fetch the complete documentation index at: https://docs.buildassistants.app/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Replying Tag

## How the AI Replying Tag Works

Whenever an AI is replying to a contact, that information can be seen in the AI portal as the AI is replying. But if you would like to trigger a workflow or have additional functionality around analysis and information pulling - the tag **`ai_replying`** is added during AI generation.

Whenever a message has come through with an active tag, just like in the portal with the general animation, the tag is added before generation, and removed on successful send to the CRM (i.e. messageId is available from the send).

## Use Cases

### Fallbacks

Use the **`ai_replying`** tag to trigger a workflow with a wait timeout for reply sending. This can be helpful in the event of:

* **Vendor or platform timeout/server maintenance**
* **Decision making around replies**
* **Quality control and monitoring**
* **Backup response systems**

## How It Works

### Tag Lifecycle

1. **Tag Added:** When AI begins generating a response (before generation starts)
2. **AI Processing:** Tag remains active during AI response generation
3. **Tag Removed:** When message is successfully sent to CRM (messageId is available)

### Workflow Integration

You can create workflows that trigger on the **`ai_replying`** tag to:

* Monitor AI response times
* Implement fallback mechanisms
* Track AI engagement metrics
* Handle timeout scenarios

## Implementation Examples

### Fallback Workflow Setup

1. **Trigger:** Contact tagged with `ai_replying`
2. **Wait Action:** Set timeout period (e.g., 30 seconds)
3. **Condition:** Check if tag still exists after timeout
4. **Fallback Action:** Send backup response or alert human agent

### Monitoring Workflow

1. **Trigger:** Contact tagged with `ai_replying`
2. **Action:** Log timestamp and contact information
3. **Wait:** For tag removal (successful send)
4. **Action:** Calculate and log response time

## Key Benefits

* ✅ **Real-time monitoring** of AI response generation
* ✅ **Fallback mechanisms** for system reliability
* ✅ **Response time tracking** for performance analysis
* ✅ **Quality control workflows** for AI interactions
* ✅ **Automatic tag management** without manual intervention
* ✅ **CRM integration** with messageId confirmation

## Best Practices

**Timeout Settings:**

* Set appropriate wait times based on expected AI response duration
* Consider network latency and processing time
* Test timeout thresholds with various query types

**Fallback Strategies:**

* Prepare backup responses for common scenarios
* Alert human agents when AI fails to respond
* Log timeout events for system monitoring

**Monitoring:**

* Track AI response times for performance optimization
* Monitor tag lifecycle for system health
* Use data for improving AI efficiency

## Troubleshooting

**Tag not being added:**

* Verify Active Tags are properly configured
* Check if AI assistant is correctly linked
* Ensure contact has appropriate permissions

**Tag not being removed:**

* Check CRM connection status
* Verify messageId is being generated
* Review AI response completion process

**Workflow not triggering:**

* Confirm workflow trigger is set to `ai_replying` tag
* Check workflow activation status
* Verify contact enrollment criteria
