AIMI Tier 1 Agent Builder script
Copy this script into Script mode when you create the AIMI : Tier 1 Agent in Agentforce Studio. See Set up MIC AI for the full procedure.
Before you commit the script in Agent Builder:
- Replace
default_agent_userwith the Einstein service agent user username for your org (the example value below is org-specific). - When prompted to select an Agent User, choose Einstein ServiceAgent User (or the Einstein service agent user record created for this agent).
system:
instructions: "You are an agent whose task is to assist medical information specialists in managing requests, adverse events, and product quality complaints."
messages:
welcome: |
Hi, I'm an AI service assistant. How can I help you?
error: "Sorry, it looks like something has gone wrong."
config:
agent_label: "AIMI : Tier 1 Agent"
developer_name: "MAI_AIMI_Tier_1_Agent"
description: "Automate day to day tasks for Medical Information Specialists and assist in their flow of work."
default_agent_user: "mai_aimi_tier_1_agent@00drk00000vp5et1250010821.ext"
language:
default_locale: "en_US"
additional_locales: "en_GB"
all_additional_locales: False
variables:
interactionId: mutable string
label: "interactionId"
description: "Used to store record Id of the Interaction"
visibility: "External"
interactionRecord: mutable object
label: "interactionRecord"
description: "Used to store the Interaction with the provided interactionId"
Product_and_Question_Prompt_Response: mutable string
label: "Product and Question Prompt Response"
description: "Used to store the prompt template response for the identified products and questions."
responseLogId: mutable string
label: "responseLogId"
description: "Used to store the record Id of the AIMI response log"
visibility: "External"
aimiResponseLog: mutable object
label: "aimiResponseLog"
description: "Used to store the AIMI response log with the provided responseLogId"
Category_Prompt_Response: mutable string
label: "Category Prompt Response"
description: "Used to store the response from the prompt for suggesting category and sub-category"
PQC_Recommendation_Prompt_Response: mutable string
label: "PQC Recommendation Prompt Response"
description: "Used to store the response from the prompt template for the PQC recommendation"
AE_Recommendation_Prompt_Response: mutable string
description: "Used to store the prompt response for Adverse Event recommendation"
label: "AE Recommendation Prompt Response"
Interaction_Summary_Prompt_Response: mutable string
description: "Used to store the prompt response for Interaction summary"
label: "Interaction Summary Prompt Response"
knowledge:
rag_feature_config_id: ""
citations_enabled: False
citations_url: ""
start_agent topic_selector:
label: "Topic Selector"
description: "Welcome the user and determine the appropriate topic based on user input"
reasoning:
instructions: ->
| Select the best tool to call based on conversation history and user's intent.
actions:
go_to_MAI_Request_Management: @utils.transition to @subagent.MAI_Request_Management
go_to_MAI_Product_Quality_Complaint_Management: @utils.transition to @subagent.MAI_Product_Quality_Complaint_Management
go_to_MAI_Adverse_Event_Recommendation: @utils.transition to @subagent.MAI_Adverse_Event_Recommendation
go_to_MAI_Interaction_Management: @utils.transition to @subagent.MAI_Interaction_Management
subagent MAI_Request_Management:
label: "Request Management"
description: "Use this subagent when the user asks to suggest products and questions, suggest category and sub-category for a request."
reasoning:
instructions: ->
| When the user asks to suggest products and question for a request, follow the steps below in the defined order
| Get the Interaction details using the action {!@actions.MAI_AIMI_Agent_Get_Interaction_Details}
| Use the action {!@actions.MAI_AIMI_Interaction_Product_And_Question} with the interaction record.
| Use the {!@variables.Product_and_Question_Prompt_Response} and create request records per element using the action {!@actions.MAI_AIMI_Agent_Create_Request_Response_Log}
| When the user asks to suggest category and sub-category for a request, follow the steps below in the defined order
| Get the Response log details using the action {!@actions.MAI_AIMI_Agent_Get_Response_Log}
| Use the action {!@actions.MAI_AIMI_Response_Log_Suggest_Category} with the response log record.
| Then use the {!@variables.Category_Prompt_Response} and call the action {!@actions.MAI_AIMI_Agent_Update_Response_Log} to update the response log with the identified category and sub-category
actions:
MAI_AIMI_Agent_Get_Interaction_Details: @actions.MAI_AIMI_Agent_Get_Interaction_Details
with interactionId = @variables.interactionId
set @variables.interactionRecord = @outputs.interactionRecord
MAI_AIMI_Agent_Get_Response_Log: @actions.MAI_AIMI_Agent_Get_Response_Log
with responseLogId = @variables.responseLogId
set @variables.aimiResponseLog = @outputs.responseLog
MAI_AIMI_Agent_Create_Request_Response_Log: @actions.MAI_AIMI_Agent_Create_Request_Response_Log
with interactionId = @variables.interactionId
with productName = ...
with question = ...
MAI_AIMI_Response_Log_Suggest_Category: @actions.MAI_AIMI_Response_Log_Suggest_Category
with "Input:AIMI_Response_Log" = @variables.aimiResponseLog
set @variables.Category_Prompt_Response = @outputs.promptResponse
MAI_AIMI_Interaction_Product_And_Question: @actions.MAI_AIMI_Interaction_Product_And_Question
with "Input:Interaction" = @variables.interactionRecord
set @variables.Product_and_Question_Prompt_Response = @outputs.promptResponse
MAI_AIMI_Agent_Update_Response_Log: @actions.MAI_AIMI_Agent_Update_Response_Log
with category = ...
with requestType = ...
with responseLogId = ...
with subCategory = ...
actions:
MAI_AIMI_Agent_Get_Interaction_Details:
description: |
This flow is used to get the details of an Interaction with the provided record Id
label: "AIMI Agent : Get Interaction Details"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Get_Interaction_Details"
target: "flow://MAI_AIMI_Agent_Get_Interaction_Details"
inputs:
"interactionId": string
description: |
Used to get the Interaction record with the provided Id
label: "interactionId"
is_required: True
is_user_input: False
outputs:
"interactionRecord": object
description: |
Used to store the Interaction record
label: "interactionRecord"
is_displayable: True
filter_from_agent: False
complex_data_type_name: "lightning__recordInfoType"
MAI_AIMI_Agent_Get_Response_Log:
description: |
This flow is used to get the response log with the provided record Id
label: "AIMI Agent : Get Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Get_Response_Log"
target: "flow://MAI_AIMI_Agent_Get_Response_Log"
inputs:
"responseLogId": string
description: |
Used to store the record Id of the AIMI response log
label: "responseLogId"
is_required: True
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the success or fault message to display to the user.
label: "OUTPUT_MSG"
is_displayable: True
filter_from_agent: False
"responseLog": object
description: |
Used to store the response log with the provided record Id
label: "responseLog"
is_displayable: False
filter_from_agent: False
complex_data_type_name: "lightning__recordInfoType"
MAI_AIMI_Agent_Create_Request_Response_Log:
description: |
This flow is used to create the AIMI response log for the "Request" record type and sets the Product name and Question
label: "AIMI Agent: Create Request Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Create_Request_Response_Log"
target: "flow://MAI_AIMI_Agent_Create_Request_Response_Log"
inputs:
"interactionId": string
description: |
Used to store the record Id of the Interaction record to which the response log will be attached
label: "interactionId"
is_required: True
is_user_input: False
"productName": string
description: |
Used to store the name of the product
label: "productName"
is_required: True
is_user_input: False
"question": string
description: |
Used to store the question related to the product
label: "question"
is_required: True
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the success or fault message to display to the user.
label: "OUTPUT_MSG"
is_displayable: True
filter_from_agent: False
MAI_AIMI_Response_Log_Suggest_Category:
description: |
This template is used to get the category and sub-category based on the question
label: "AIMI Response Log : Suggest Category"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Response_Log_Suggest_Category"
target: "generatePromptResponse://MAI_AIMI_Response_Log_Suggest_Category"
inputs:
"Input:AIMI_Response_Log": object
description: |
The response log record for which category and sub-category needs to be suggested
label: "AIMI Response Log"
is_required: True
is_user_input: False
complex_data_type_name: "lightning__recordInfoType"
outputs:
"promptResponse": string
description: |
The prompt response generated by the action based on the specified prompt and input.
label: "Prompt Response"
is_displayable: True
filter_from_agent: False
MAI_AIMI_Interaction_Product_And_Question:
description: |
This prompt template is used to identify the question and product for a request based on the email message content for an Interaction.
label: "Interaction: Product And Question"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Interaction_Product_And_Question"
target: "generatePromptResponse://MAI_Interaction_Product_And_Question"
inputs:
"Input:Interaction": object
description: |
The interaction record to use in the prompt template
label: "Interaction"
is_required: True
is_user_input: False
complex_data_type_name: "lightning__recordInfoType"
outputs:
"promptResponse": string
description: |
The prompt response generated by the action based on the specified prompt and input.
label: "Prompt Response"
is_displayable: True
filter_from_agent: False
MAI_AIMI_Agent_Update_Response_Log:
description: |
This flow is used to update the category and sub-category values for an AIMI response log
label: "AIMI Agent: Update Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Update_Response_Log"
target: "flow://MAI_AIMI_Agent_Update_Response_Log"
inputs:
"category": string
description: |
Used to store the identified category for the response log record
label: "category"
is_required: False
is_user_input: False
"requestType": string
description: |
Used to store the identified request type for the response log record
label: "requestType"
is_required: False
is_user_input: False
"responseLogId": string
description: |
Used to store the record Id of the AIMI response log for which category and sub-category needs to be updated
label: "responseLogId"
is_required: True
is_user_input: False
"subCategory": string
description: |
Used to store the identified sub-category for the response log record
label: "subCategory"
is_required: False
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the message to be displayed to the end user
label: "OUTPUT_MSG"
is_displayable: True
filter_from_agent: False
subagent MAI_Product_Quality_Complaint_Management:
label: "Product Quality Complaint Management"
description: "Use this subagent when the user asks to provide recommendation for a PQC for an Interaction."
reasoning:
instructions: ->
|When the user asks to Recommend PQC for the Interaction, follow the below steps in the defined order
1. Get the Interaction details using the action {!@actions.MAI_AIMI_Agent_Get_Interaction_Details}
2. Use the action {!@actions.MAI_Interaction_Product_Complaint_Recommendation}
3. Use the action {!@actions.MAI_AIMI_Agent_Create_PQC_Response_Log}to create the PQC response log from the response {!@variables.PQC_Recommendation_Prompt_Response}
actions:
MAI_AIMI_Agent_Get_Interaction_Details: @actions.MAI_AIMI_Agent_Get_Interaction_Details
with interactionId = @variables.interactionId
set @variables.interactionRecord = @outputs.interactionRecord
MAI_Interaction_Product_Complaint_Recommendation: @actions.MAI_Interaction_Product_Complaint_Recommendation
with "Input:Interaction" = @variables.interactionRecord
set @variables.PQC_Recommendation_Prompt_Response = @outputs.promptResponse
MAI_AIMI_Agent_Create_PQC_Response_Log: @actions.MAI_AIMI_Agent_Create_PQC_Response_Log
with interactionId = @variables.interactionId
with justification = ...
with productName = ...
with complaint = ...
with recommendation = ...
actions:
MAI_AIMI_Agent_Get_Interaction_Details:
description: |
This flow is used to get the details of an Interaction with the provided record Id
label: "AIMI Agent : Get Interaction Details"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Get_Interaction_Details"
target: "flow://MAI_AIMI_Agent_Get_Interaction_Details"
inputs:
"interactionId": string
description: |
Used to get the Interaction record with the provided Id
label: "interactionId"
is_required: True
is_user_input: False
outputs:
"interactionRecord": object
description: |
Used to store the Interaction record
label: "interactionRecord"
is_displayable: True
filter_from_agent: False
complex_data_type_name: "lightning__recordInfoType"
MAI_Interaction_Product_Complaint_Recommendation:
description: |
Recommends if a Product Complaint may have occurred. The general pharmaceutical industry definitions in this prompt should be updated to include client-specific terms.
label: "Interaction: Product Complaint Recommendation"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_Interaction_Product_Complaint_Recommendation"
target: "generatePromptResponse://MAI_Interaction_Product_Complaint_Recommendation"
inputs:
"Input:Interaction": object
description: |
The interaction record for which product quality complaint needs to be recommended
label: "Interaction"
is_required: True
is_user_input: False
complex_data_type_name: "lightning__recordInfoType"
outputs:
"promptResponse": string
description: |
The prompt response generated by the action based on the specified prompt and input.
label: "Prompt Response"
is_displayable: True
filter_from_agent: False
MAI_AIMI_Agent_Create_PQC_Response_Log:
description: |
This flow is used to create the PQC type AIMI response log
label: "AIMI Agent: Create PQC Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Create_PQC_Response_Log"
target: "flow://MAI_AIMI_Agent_Create_PQC_Response_Log"
inputs:
"interactionId": string
description: |
Used to store the record Id of the Interaction record to which the response log will be attached
label: "interactionId"
is_required: True
is_user_input: False
"justification": string
description: |
Used to store the justification provided to recommend the PQC
label: "justification"
is_required: True
is_user_input: False
"productName": string
description: |
Used to store the name of the product
label: "productName"
is_required: False
is_user_input: False
"complaint": string
description: |
Used to store the complaint provided by the prompt template for the Product Quality Complaint (PQC)
label: "complaint"
is_required: False
is_user_input: False
"recommendation": string
description: |
Recommendation provided by the prompt template for the Product quality complaint
label: "recommendation"
is_required: True
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the success or fault message to display to the user.
label: "OUTPUT_MSG"
is_displayable: True
filter_from_agent: False
subagent MAI_Adverse_Event_Recommendation:
label: "Adverse Event Recommendation"
description: "Use this subagent when the user asks to check for an Adverse reaction for an Interaction."
reasoning:
instructions: ->
|When the user asks to to check for an adverse reaction for the Interaction, follow the below steps in the defined order
1. Get the Interaction details using the action {!@actions.MAI_AIMI_Agent_Get_Interaction_Details}
2. Use the action {!@actions.MAI_Interaction_Adverse_Event_Recommendation}
3. Use the action {!@actions.MAI_AIMI_Agent_Create_AE_Response_Log} to create the AE response log from the response {!@variables.AE_Recommendation_Prompt_Response}
actions:
MAI_AIMI_Agent_Get_Interaction_Details: @actions.MAI_AIMI_Agent_Get_Interaction_Details
with interactionId = @variables.interactionId
set @variables.interactionRecord = @outputs.interactionRecord
MAI_AIMI_Agent_Create_AE_Response_Log: @actions.MAI_AIMI_Agent_Create_AE_Response_Log
with interactionId = @variables.interactionId
with justification = ...
with narrative = ...
with productName = ...
with recommendation = ...
MAI_Interaction_Adverse_Event_Recommendation: @actions.MAI_Interaction_Adverse_Event_Recommendation
with "Input:Interaction" = @variables.interactionRecord
set @variables.AE_Recommendation_Prompt_Response = @outputs.promptResponse
actions:
MAI_AIMI_Agent_Get_Interaction_Details:
description: |
This flow is used to get the details of an Interaction with the provided record Id
label: "AIMI Agent : Get Interaction Details"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Get_Interaction_Details"
target: "flow://MAI_AIMI_Agent_Get_Interaction_Details"
inputs:
"interactionId": string
description: |
Used to get the Interaction record with the provided Id
label: "interactionId"
is_required: True
is_user_input: False
outputs:
"interactionRecord": object
description: |
Used to store the Interaction record
label: "interactionRecord"
is_displayable: True
filter_from_agent: False
complex_data_type_name: "lightning__recordInfoType"
MAI_AIMI_Agent_Create_AE_Response_Log:
description: |
This flow is used to create an Adverse Event type response log
label: "AIMI Agent: Create AE Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Create_AE_Response_Log"
target: "flow://MAI_AIMI_Agent_Create_AE_Response_Log"
inputs:
"interactionId": string
description: |
Used to store the record Id of the Interaction record to which the response log will be attached
label: "interactionId"
is_required: True
is_user_input: False
"justification": string
description: |
Used to store the justification provided to recommend the PQC
label: "justification"
is_required: False
is_user_input: False
"narrative": string
description: |
Used to store the narrative for an Adverse Event (AE)
label: "narrative"
is_required: False
is_user_input: False
"productName": string
description: |
Used to store the name of the product
label: "productName"
is_required: False
is_user_input: False
"recommendation": string
description: |
Recommendation provided by the prompt template for the Product quality complaint
label: "recommendation"
is_required: True
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the success or fault message to display to the user.
label: "OUTPUT_MSG"
is_displayable: True
filter_from_agent: False
MAI_Interaction_Adverse_Event_Recommendation:
description: |
Recommends whether or not an Adverse Event has occurred. The general pharmaceutical industry definitions in this prompt should be updated to include client-specific terms.
label: "Interaction: Adverse Event Recommendation"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_Interaction_Adverse_Event_Recommendation"
target: "generatePromptResponse://MAI_Interaction_AE_Recommendation"
inputs:
"Input:Interaction": object
description: |
The interaction record for which the Adverse Event recommendation needs to be provided.
label: "Interaction"
is_required: True
is_user_input: False
complex_data_type_name: "lightning__recordInfoType"
outputs:
"promptResponse": string
description: |
The prompt response generated by the action based on the specified prompt and input.
label: "Prompt Response"
is_displayable: True
filter_from_agent: False
subagent MAI_Interaction_Management:
label: "Interaction Management"
description: "Use this subagent when the user asks to provide summary for an Interaction"
reasoning:
instructions: ->
| When the user asks to provide summary for an Interaction, follow the below steps in the defined order
1. Get the Interaction details using the action {!@actions.MAI_AIMI_Agent_Get_Interaction_Details}
2. Use the action {!@actions.MAI_Interaction_Summary}
3. Use the action {!@actions.MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log} to create the summary response log from the response {!@variables.Interaction_Summary_Prompt_Response}
actions:
MAI_AIMI_Agent_Get_Interaction_Details: @actions.MAI_AIMI_Agent_Get_Interaction_Details
with interactionId = @variables.interactionId
set @variables.interactionRecord = @outputs.interactionRecord
MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log: @actions.MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log
with interactionId = @variables.interactionId
with summary = ...
MAI_Interaction_Summary: @actions.MAI_Interaction_Summary
with "Input:Interaction" = @variables.interactionRecord
with outputLanguage = ...
with isPreviewOnly = ...
set @variables.Interaction_Summary_Prompt_Response = @outputs.promptResponse
actions:
MAI_AIMI_Agent_Get_Interaction_Details:
description: |
This flow is used to get the details of an Interaction with the provided record Id
label: "AIMI Agent : Get Interaction Details"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Get_Interaction_Details"
target: "flow://MAI_AIMI_Agent_Get_Interaction_Details"
inputs:
"interactionId": string
description: |
Used to get the Interaction record with the provided Id
label: "interactionId"
is_required: True
is_user_input: False
outputs:
"interactionRecord": object
description: |
Used to store the Interaction record
label: "interactionRecord"
is_displayable: True
filter_from_agent: False
complex_data_type_name: "lightning__recordInfoType"
MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log:
description: |
This flow is used to create the Summary type AIMI response log
label: "AIMI Agent: Create Interaction Summary Response Log"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log"
target: "flow://MAI_AIMI_Agent_Create_Interaction_Summary_Response_Log"
inputs:
"interactionId": string
description: |
Used to store the record Id of the Interaction record to which the response log will be attached
label: "interactionId"
is_required: False
is_user_input: False
"summary": string
description: |
Summary provided by the prompt
label: "summary"
is_required: False
is_user_input: False
outputs:
"OUTPUT_MSG": string
description: |
Used to store the success or fault message to display to the user.
label: "OUTPUT_MSG"
is_displayable: False
filter_from_agent: False
MAI_Interaction_Summary:
description: |
This prompt template is used to generate the summary for an Interaction including its requests, content notes, and email content.
label: "Interaction: Summary"
require_user_confirmation: False
include_in_progress_indicator: False
source: "MAI_Interaction_Summary"
target: "generatePromptResponse://MAI_Interaction_Summary"
inputs:
"Input:Interaction": object
description: |
The interaction record for which summary needs to be generated.
label: "Interaction"
is_required: True
is_user_input: False
complex_data_type_name: "lightning__recordInfoType"
"outputLanguage": string
description: |
Optional. Specify the response language using the appropriate two-character language code or five-character locale code (for example, en_US, en_GB, es, es_MX).
label: "Output language"
is_required: False
is_user_input: False
"isPreviewOnly": boolean
description: |
Resolves the prompt template without generating an LLM response.
label: "Preview Only"
is_required: False
is_user_input: False
outputs:
"promptResponse": string
description: |
The prompt response generated by the action based on the specified prompt and input.
label: "Prompt Response"
is_displayable: True
filter_from_agent: False