APIs & Integrations

GKaisarlis
Member

Assign ticket to Agent from a livechat

SOLVE

Hi,
I have an external API integration with a Live Chat. After some interactions with an established webhook i want to assign the ticket to a new Agent -User.

So far by using the conversations API  i have not managed to find a way to assign it to another agent

by using PATCH https://api.hubapi.com/conversations/v3/conversations/threads/xxxx

with body

 

 

{   
     "assignedTo": "A-{new Agent}",
}

 

0 Upvotes
1 Accepted solution
GKaisarlis
Solution
Member

Assign ticket to Agent from a livechat

SOLVE

Finally i have figured out a workaround to re assign a conversation related to a ticket to another agent.

1. find ticket

get thread_id from conversation


search ticket_id from
POST https://api.hubapi.com/crm/v3/objects/tickets/search

{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_conversations_originating_thread_id",
"operator": "EQ",
"value": 8270568984
}
]
}
]
}


response


{
"total": 1,
"results": [
{
"id": "15733618451",
"properties": {
"content": null,
"createdate": "2024-10-24T14:02:44.363Z",
"hs_lastmodifieddate": "2024-11-07T11:26:21.865Z",
"hs_object_id": "15733618451",
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_category": null,
"hs_ticket_priority": null,
"subject": "Ticket #15733618451"
},
"createdAt": "2024-10-24T14:02:44.363Z",
"updatedAt": "2024-11-07T11:26:21.865Z",
"archived": false
}
]
}



get the ticket_id from id property



2.find owner_id from the ticket
GET https://api.hubapi.com/crm/v3/objects/tickets/16408157700?properties=hubspot_owner_id

Response

{
"id": "16408157700",
"properties": {
"createdate": "2024-11-14T16:30:01.399Z",
"hs_lastmodifieddate": "2024-11-16T06:16:13.684Z",
"hs_object_id": "16408157700",
"hubspot_owner_id": "210570159"
},
"createdAt": "2024-11-14T16:30:01.399Z",
"updatedAt": "2024-11-16T06:16:13.684Z",
"archived": false
}



3. check owners
GET https://api.hubapi.com/crm/v3/owners/

id is the property for reassign and user_id is used to respond as an agent with an A- infront


{
"results": [
{
"id": "210554153",
"email": "xxxxxx",
"type": "PERSON",
"firstName": "xxxx",
"lastName": "xxxxxx",
"userId": 9898134,
"userIdIncludingInactive": 9898134,
"createdAt": "2022-07-29T14:03:15.582Z",
"updatedAt": "2022-08-22T07:40:12.108Z",
"archived": false
},
{
"id": "210554155",
"email": "xxxxxxx",
"type": "PERSON",
"firstName": "xxxx",
"lastName": "xxxx",
"userId": 10404843,
"userIdIncludingInactive": 10404843,
"createdAt": "2022-07-29T14:03:15.661Z",
"updatedAt": "2022-07-29T14:03:15.661Z",
"archived": false
}
]
}


check the one that we want and get the id


4. change owner of a ticket
PATCH https://api.hubapi.com/crm/v3/objects/tickets/16199285664?properties=hubspot_owner_id
with body

{
"properties": {
"hubspot_owner_id": 1192786586
}
}

Response

{
"id": "16199285664",
"properties": {
"createdate": "2024-11-09T13:33:33.242Z",
"hs_all_accessible_team_ids": "",
"hs_all_owner_ids": "1192786586",
"hs_helpdesk_sort_timestamp": "2024-11-09T13:37:23.064Z",
"hs_last_message_received_at": "2024-11-09T13:37:23.064Z",
"hs_lastmodifieddate": "2024-11-16T06:19:06.406Z",
"hs_object_id": "16199285664",
"hs_object_source": "CONVERSATIONS",
"hs_object_source_label": "CONVERSATIONS",
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_id": "16199285664",
"hs_user_ids_of_all_owners": "72747601",
"hubspot_owner_assigneddate": "2024-11-16T06:19:04.738Z",
"hubspot_owner_id": "1192786586"
},
"createdAt": "2024-11-09T13:33:33.242Z",
"updatedAt": "2024-11-16T06:19:06.406Z",
"archived": false
}






View solution in original post

0 Upvotes
3 Replies 3
GKaisarlis
Solution
Member

Assign ticket to Agent from a livechat

SOLVE

Finally i have figured out a workaround to re assign a conversation related to a ticket to another agent.

1. find ticket

get thread_id from conversation


search ticket_id from
POST https://api.hubapi.com/crm/v3/objects/tickets/search

{
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_conversations_originating_thread_id",
"operator": "EQ",
"value": 8270568984
}
]
}
]
}


response


{
"total": 1,
"results": [
{
"id": "15733618451",
"properties": {
"content": null,
"createdate": "2024-10-24T14:02:44.363Z",
"hs_lastmodifieddate": "2024-11-07T11:26:21.865Z",
"hs_object_id": "15733618451",
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_category": null,
"hs_ticket_priority": null,
"subject": "Ticket #15733618451"
},
"createdAt": "2024-10-24T14:02:44.363Z",
"updatedAt": "2024-11-07T11:26:21.865Z",
"archived": false
}
]
}



get the ticket_id from id property



2.find owner_id from the ticket
GET https://api.hubapi.com/crm/v3/objects/tickets/16408157700?properties=hubspot_owner_id

Response

{
"id": "16408157700",
"properties": {
"createdate": "2024-11-14T16:30:01.399Z",
"hs_lastmodifieddate": "2024-11-16T06:16:13.684Z",
"hs_object_id": "16408157700",
"hubspot_owner_id": "210570159"
},
"createdAt": "2024-11-14T16:30:01.399Z",
"updatedAt": "2024-11-16T06:16:13.684Z",
"archived": false
}



3. check owners
GET https://api.hubapi.com/crm/v3/owners/

id is the property for reassign and user_id is used to respond as an agent with an A- infront


{
"results": [
{
"id": "210554153",
"email": "xxxxxx",
"type": "PERSON",
"firstName": "xxxx",
"lastName": "xxxxxx",
"userId": 9898134,
"userIdIncludingInactive": 9898134,
"createdAt": "2022-07-29T14:03:15.582Z",
"updatedAt": "2022-08-22T07:40:12.108Z",
"archived": false
},
{
"id": "210554155",
"email": "xxxxxxx",
"type": "PERSON",
"firstName": "xxxx",
"lastName": "xxxx",
"userId": 10404843,
"userIdIncludingInactive": 10404843,
"createdAt": "2022-07-29T14:03:15.661Z",
"updatedAt": "2022-07-29T14:03:15.661Z",
"archived": false
}
]
}


check the one that we want and get the id


4. change owner of a ticket
PATCH https://api.hubapi.com/crm/v3/objects/tickets/16199285664?properties=hubspot_owner_id
with body

{
"properties": {
"hubspot_owner_id": 1192786586
}
}

Response

{
"id": "16199285664",
"properties": {
"createdate": "2024-11-09T13:33:33.242Z",
"hs_all_accessible_team_ids": "",
"hs_all_owner_ids": "1192786586",
"hs_helpdesk_sort_timestamp": "2024-11-09T13:37:23.064Z",
"hs_last_message_received_at": "2024-11-09T13:37:23.064Z",
"hs_lastmodifieddate": "2024-11-16T06:19:06.406Z",
"hs_object_id": "16199285664",
"hs_object_source": "CONVERSATIONS",
"hs_object_source_label": "CONVERSATIONS",
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_id": "16199285664",
"hs_user_ids_of_all_owners": "72747601",
"hubspot_owner_assigneddate": "2024-11-16T06:19:04.738Z",
"hubspot_owner_id": "1192786586"
},
"createdAt": "2024-11-09T13:33:33.242Z",
"updatedAt": "2024-11-16T06:19:06.406Z",
"archived": false
}






0 Upvotes
GKaisarlis
Member

Assign ticket to Agent from a livechat

SOLVE

Thanks for the response.
I have a conversation new message event  that triggers a webhook to an external api and i need after some calls the associated ticket (with the conversation) to be forwarded to the another agent.


GKaisarlis_0-1731600602514.png

 



0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Assign ticket to Agent from a livechat

SOLVE

Hey, @GKaisarlis 👋 You mention conversations and tickets. To clarify, are you looking to assign a ticket that is associated to a conversation to another user? If so, you may need to look at the Tickets API and the Associations API

 

Hey, @TomM2 @Olivia_Bagnall @dsmarion, do you have any additional suggestions for @GKaisarlis?

 

 Thanks for clarifying! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes