From Bright Pattern Documentation
Jump to: navigation, search
• 5.19

Ask AI

The Ask AI scenario block is used for AI-driven data extraction and content generation within Workflows, Email scenarios, and Task scenarios. This block sends your instructions to a large language model from an AI provider. The AI processes the instructions and returns structured data, which is then saved to variables for use in the scenario.


Info.40x40.png

To provide information to the AI, you must explicitly include it in the Instruction to AI parameter using the appropriate scenario variables. No email or task content is sent automatically; this gives you full control over what information the AI receives.

To have the AI process an email, you would include the $(item.body) variable directly in the instructions. See the Instruction to AI description for an example.

You can use the email_remove_quoted_content_html or email_remove_quoted_content_plaintext functions to remove quoted replies from the email content before it is sent to the AI.


Common use cases for the Ask AI block include:

  • Automating responses
  • Extracting key details (e.g., order numbers, customer intent) for use in subsequent scenario logic
  • Drafting follow-up emails or messages for agent review
  • Categorizing inquiries for automated routing


Ask AI scenario block settings


The Ask AI block processes interactions in the following sequence:

  1. Execution: When a scenario executes the Ask AI block, it prepares a request for the selected AI provider.
  2. Request Construction: The block constructs a single prompt that includes:
    • The content from the Instruction to AI field, with any scenario variables resolved to their current values.
    • Hardcoded instructions for the AI to return its response in a valid JSON format. The structure of this JSON is dynamically defined by the fields configured in the Data to extract property.
  3. AI Processing: The request is sent to the AI provider's API. The block then waits for a response, up to the duration specified in the AI response timeout setting.
  4. Response Handling:
    • Success: If the AI provider returns a valid JSON response within the timeout period, the block parses the response. It populates the scenario variables defined in the Data to extract property with the values from the JSON. Scenario execution proceeds to the next block in the scenario.
    • Failure: If the AI provider returns an error (e.g., authentication failure, invalid request), the block populates the $(aiErrorCode) and $(aiErrorBody) variables and takes the Failed exit path.
    • Timeout: If the AI provider does not respond within the configured timeout period, the block takes the Timeout exit path.


Settings

Title Text

The name of the instance of the block in the scenario. This is an optional field.

AI Provider

Select the AI provider account to use for this block.

  • << Default >>: Uses the AI account configured by your service provider as part of the selected AI Package. If no package is assigned to your contact center, this option will show an error, and you will need to contact your service provider.
  • You may also select from any AI provider integration accounts configured in your contact center.

Instruction to AI

A required text field where you provide clear, specific instructions for the AI. Use scenario variables to include dynamic content, such as the body of an email or a case description.

The field is pre-filled with grey helper text that provides an example of how to structure an instruction. This text is removed as soon as you begin typing.

Example instructions:

Analyze the incoming email from the customer. 
Provide the following:
* The reason for contact
* A brief summary of the issue
* If an order ID is mentioned, extract it; otherwise, return 'false' for the order_id variable. 

Email content: 

```
$(item.body)
```

Data to extract

This section defines the structured data you want the AI to return. At least one output data point must be configured for the block to execute and for the scenario to be considered valid.

Clicking add Output Data opens a dialog where you define each piece of data to be extracted:

  • Variable name: The name of the scenario variable that will store the extracted data (e.g., order_id).
  • Data description: A natural language description of the data to be extracted. This helps the AI understand what information to look for (e.g., The customer's order ID mentioned in the email).
  • Example value: Optionally provide an example value to assist the AI.


Define the data to extract from the instructions


AI response timeout

The maximum time (in seconds) that the system will wait for the AI to provide a response before taking the Timeout exit. The value can be set between 1 and 300 seconds, with a default of 100.

Model temperature

Controls the creativity of the AI-generated response. For a complete description, refer to the Model temperature setting of the AI Agent block.

Exits

Failed

This conditional exit is taken if an error occurs during the request to the AI provider. The branch from this exit should gracefully handle such failures.

Timeout

This conditional exit is taken if the AI provider fails to respond within the time specified in the AI response timeout setting. You must draw a branch from this exit to handle timeouts.

Variables

Token Usage Variables

The same Token usage variables as the AI Agent scenario block.

Error Variables

The same Error variables as the AI Agent scenario block.

< Previous