Create and patch engagement

Hi,

I’m having some issues understanding the engagement api.

Here’s what I’m doing with the results of each call:

I start from this situation, the filter has only CALLS selected:

I then POST a request to create a new CALL engagement:

curl -X 'POST' -H 'Content-Type: application/json' "https://api.hubapi.com/engagements/v1/engagements?hapikey=${APIKEY}" --data '{
 "engagement": {
 "type": "CALL"
 },
 "associations": {
 "contactIds": [
 51
 ],
 "ownerIds": [
 1
 ]
 },
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "IN_PROGRESS"
 }
}'

{
 "associationCreateFailures": [],
 "engagement": {
 "id": 10141331606,
 "portalId": 8642268,
 "active": true,
 "createdAt": 1607615292658,
 "lastUpdated": 1607615292658,
 "type": "CALL",
 "timestamp": 1607615292658,
 "allAccessibleTeamIds": [],
 "queueMembershipIds": [],
 "gdprDeleted": false
 },
 "associations": {
 "contactIds": [
 51
 ],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": [
 1
 ],
 "workflowIds": [],
 "ticketIds": [],
 "contentIds": [],
 "quoteIds": []
 },
 "attachments": [],
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "IN_PROGRESS"
 }
}

I refresh the page and this is what I see (up to this point is all as expected):

After a few seconds I send a PATCH request:

curl -X 'PATCH' -H 'Content-Type: application/json' "https://api.hubapi.com/engagements/v1/engagements/10141331606?hapikey=${APIKEY}" --data '{
 "metadata": {
 "status": "COMPLETED",
 "durationMilliseconds": "29000"
 }
}'

{
 "engagement": {
 "id": 10141331606,
 "portalId": 8642268,
 "active": true,
 "createdAt": 1607615292658,
 "lastUpdated": 1607615332412,
 "type": "CALL",
 "timestamp": 1607615292658,
 "allAccessibleTeamIds": [],
 "queueMembershipIds": [],
 "gdprDeleted": false
 },
 "associations": {
 "contactIds": [],
 "companyIds": [],
 "dealIds": [],
 "ownerIds": [
 1
 ],
 "workflowIds": [],
 "ticketIds": [],
 "contentIds": [],
 "quoteIds": []
 },
 "attachments": [],
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "COMPLETED",
 "durationMilliseconds": 29000
 }
}

I then refresh the page again and here’s the problem:

It appears that the PATCH requests creates another call instead of updating the existing one.

Can someone help?

Thanks.

Hey @SycoLTH ,

I am going to try to replicate this on my end an

Hi,

Thanks for looking into this.

I just found out that it does the same wihtout the second step:

This query also creates 2 calls engagements for me, one with the right owner and duration, and the other one with the default admin as owner.

curl -s -X POST -H 'Content-Type: application/json' --data '{
 "engagement": {
 "active": true,
 "type": "CALL",
 "ownerId": 55175625
 },
 "associations": {
 "contactIds": [1],
 "ownerIds": [55175625]
 },
 "metadata": {
 "toNumber": "+35310000000",
 "fromNumber": "+353123456789",
 "status": "COMPLETED",
 "durationMilliseconds": "29000"
 }
}' "https://api.hubapi.com/engagements/v1/engagements?hapikey=${APIKEY}" | jq .

A

Also (and then I’ll stop posting and let you investigate the issue), if I exec that curl command multiple times, let’s say 3 times, I get 3 valid call engagements, and 1 phantom call at the top.

Note that I don’t have any other engagement for this account before testing this (this could also be a factor).

Thanks

Hi, any update on this?
I still see 1 phantom call at the top of every contact.

Thanks

@SycoLTH

First of all, apologies for not getting back to you on this.

Secondly, I am not able to reproduce it and I used the exact code blocks that you posted :thinking:

@RMones (apolgies for the numerous tags today), are you able to replicate this issue?

Hehe no problem @dennisedson! There will be a day then I aks you for a Hubspot T-shirt :joy:

I tried it also with the latest code example you send, But changed only the following fields:
FROM “ownerId”: 55175625 TO “ownerId”: 1

FROM: “contactIds”: [1] TO “contactIds”: [55175625],
FROM “ownerIds”: [55175625] TO “ownerIds”: [1] “ownerId”: 55175625

And then the result is as expected (one call of 29 seconds):

Regards Ronald