feat: APIs to assign agents_bots as assignee in conversations (#12836)
## Summary - add an assignee_agent_bot_id column as an initital step to prototype this before fully switching to polymorphic assignee - update assignment APIs and conversation list / show endpoints to reflect assignee as agent bot - ensure webhook payloads contains agent bot assignee [Codex Task](https://chatgpt.com/codex/tasks/task_e_6912833377e48326b6641b9eee32d50f) --------- Co-authored-by: Pranav <pranav@chatwoot.com>
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
json.payload do
|
||||
json.assignee @conversation.assignee
|
||||
json.conversation_id @conversation.display_id
|
||||
end
|
||||
@@ -7,10 +7,16 @@ json.meta do
|
||||
json.partial! 'api/v1/models/contact', formats: [:json], resource: conversation.contact
|
||||
end
|
||||
json.channel conversation.inbox.try(:channel_type)
|
||||
if conversation.assignee&.account
|
||||
if conversation.assigned_entity.is_a?(AgentBot)
|
||||
json.assignee do
|
||||
json.partial! 'api/v1/models/agent', formats: [:json], resource: conversation.assignee
|
||||
json.partial! 'api/v1/models/agent_bot_slim', formats: [:json], resource: conversation.assigned_entity
|
||||
end
|
||||
json.assignee_type 'AgentBot'
|
||||
elsif conversation.assigned_entity&.account
|
||||
json.assignee do
|
||||
json.partial! 'api/v1/models/agent', formats: [:json], resource: conversation.assigned_entity
|
||||
end
|
||||
json.assignee_type 'User'
|
||||
end
|
||||
if conversation.team.present?
|
||||
json.team do
|
||||
|
||||
6
app/views/api/v1/models/_agent_bot_slim.json.jbuilder
Normal file
6
app/views/api/v1/models/_agent_bot_slim.json.jbuilder
Normal file
@@ -0,0 +1,6 @@
|
||||
json.id resource.id
|
||||
json.name resource.name
|
||||
json.description resource.description
|
||||
json.thumbnail resource.avatar_url
|
||||
json.outgoing_url resource.outgoing_url unless resource.system_bot?
|
||||
json.bot_type resource.bot_type
|
||||
Reference in New Issue
Block a user