feat: include contact
This commit is contained in:
@@ -17,9 +17,10 @@ module Agentable
|
||||
if context
|
||||
state = context.context[:state] || {}
|
||||
conversation_data = state[:conversation] || {}
|
||||
contact_data = state[:contact] || {}
|
||||
enhanced_context = enhanced_context.merge(
|
||||
conversation: conversation_data,
|
||||
has_conversation: conversation_data.present?
|
||||
contact: contact_data
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ class Captain::Assistant::AgentRunnerService
|
||||
label_list custom_attributes additional_attributes
|
||||
].freeze
|
||||
|
||||
CONTACT_STATE_ATTRIBUTES = %i[
|
||||
id name email phone_number identifier contact_type
|
||||
custom_attributes additional_attributes
|
||||
].freeze
|
||||
|
||||
def initialize(assistant:, conversation: nil)
|
||||
@assistant = assistant
|
||||
@conversation = conversation
|
||||
@@ -103,7 +108,10 @@ class Captain::Assistant::AgentRunnerService
|
||||
assistant_config: @assistant.config
|
||||
}
|
||||
|
||||
state[:conversation] = @conversation.attributes.symbolize_keys.slice(*CONVERSATION_STATE_ATTRIBUTES) if @conversation
|
||||
if @conversation
|
||||
state[:conversation] = @conversation.attributes.symbolize_keys.slice(*CONVERSATION_STATE_ATTRIBUTES)
|
||||
state[:contact] = @conversation.contact.attributes.symbolize_keys.slice(*CONTACT_STATE_ATTRIBUTES) if @conversation.contact
|
||||
end
|
||||
|
||||
state
|
||||
end
|
||||
|
||||
@@ -10,18 +10,11 @@ You are {{ name }}, a helpful AI assistant for {{ product_name }}.
|
||||
|
||||
{{ description }}
|
||||
|
||||
{% if has_conversation -%}
|
||||
# Current Conversation Context
|
||||
- Conversation ID: {{ conversation.display_id }}
|
||||
- Status: {{ conversation.status }}
|
||||
- Priority: {{ conversation.priority }}
|
||||
{% if conversation.label_list.size > 0 -%}
|
||||
- Labels: {{ conversation.label_list | join: ", " }}
|
||||
{% endif -%}
|
||||
{% if conversation.custom_attributes -%}
|
||||
{% for attribute in conversation.custom_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% if conversation -%}
|
||||
{% render 'conversation' %}
|
||||
|
||||
{% if contact -%}
|
||||
{% render 'contact' %}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
@@ -7,18 +7,11 @@ You are a specialized agent called {{ title }}, your task is to handle the follo
|
||||
|
||||
{{ instructions }}
|
||||
|
||||
{% if has_conversation -%}
|
||||
# Current Conversation Context
|
||||
- Conversation ID: {{ conversation.display_id }}
|
||||
- Status: {{ conversation.status }}
|
||||
- Priority: {{ conversation.priority }}
|
||||
{% if conversation.label_list.size > 0 -%}
|
||||
- Labels: {{ conversation.label_list | join: ", " }}
|
||||
{% endif -%}
|
||||
{% if conversation.custom_attributes -%}
|
||||
{% for attribute in conversation.custom_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% if conversation -%}
|
||||
{% render 'conversation' %}
|
||||
|
||||
{% if contact -%}
|
||||
{% render 'contact' %}
|
||||
{% endif -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Contact Information
|
||||
- Contact ID: {{ contact.id }}
|
||||
- Name: {{ contact.name || "Unknown" }}
|
||||
- Email: {{ contact.email || "None" }}
|
||||
- Phone: {{ contact.phone_number || "None" }}
|
||||
- Identifier: {{ contact.identifier || "None" }}
|
||||
- Type: {{ contact.contact_type || "visitor" }}
|
||||
{% if contact.custom_attributes -%}
|
||||
{% for attribute in contact.custom_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{% if contact.additional_attributes -%}
|
||||
{% for attribute in contact.additional_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Current Conversation Context
|
||||
- Conversation ID: {{ conversation.display_id }}
|
||||
- Contact ID: {{ conversation.contact_id }}
|
||||
- Status: {{ conversation.status }}
|
||||
- Priority: {{ conversation.priority || "None" }}
|
||||
{% if conversation.label_list.size > 0 -%}
|
||||
- Labels: {{ conversation.label_list | join: ", " }}
|
||||
{% endif -%}
|
||||
{% if conversation.custom_attributes -%}
|
||||
{% for attribute in conversation.custom_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
{% if conversation.additional_attributes -%}
|
||||
{% for attribute in conversation.additional_attributes -%}
|
||||
- {{ attribute[0] }}: {{ attribute[1] }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
Reference in New Issue
Block a user