Engagement api update after user clicks "save" after edit causes a lose of the data

Occasional Contributor

# Current Flow
1. The call is created by our backend with the api
2. The hubspot user clicks in edit on the call description on hubspot and start writing.

3 . The call is updated by our backend with the api
4. The hubspot user clicks in "save" and reload the page.

5. The update sent by the step 3. is lost and overriten with the description that the user put in 4.

 

# Expected

The idea is that if the user edits the field manually in the dashboard the backend can still reliable update the description without getting overriten by the user action.

10 Replies 10
Highlighted
Occasional Contributor

Or is there any way to know if an Engagement with id x is been edited at the moment?

Highlighted
Occasional Contributor
Screen Shot 2019-08-26 at 5.03.33 PM.png
 
and then click in the text "Estoy escribiendo algo":
 
Screen Shot 2019-08-26 at 5.03.43 PM.png
A button "Save" (number 1) appears and then you can edit the field with the number 2.
 
The issue is that when you click"Save" (number 1) it sends the hole engagement metadata and looks like it do a PUT with all the fields (replacing any changes before that, even if it was done by  an integration in the middle of the edition and that integration only edits the other metadata beside the "description").
 
So to me it looks like there's a bug with the "save" button, that should send only the text field with number 2 value to be updated and not the hole engagement.
Reply
0 Upvotes
Highlighted
Community Manager

Hi @danielgomez,

 

I hope all is well with you 😃

 

Just to clarify the step that you took here:

1. You use the HubSpot create an engagement api to create a call engagement with e.g. metadata description: "test"

2. Next, the user may click on edit in-app and edit the description to example: "hello world"

3. Subsequently, you use the HubSpot update an engagement api to update the call engagement to e.g. "test 2"

4. The user refresh the contact page in-app and edit the description to example: "hello world 2"

 

Now, the metadata body of the call engagement will be "hello world 2" instead of "test 2", however you'd like it to be "test 2" instead of "hello world 2", am I understanding it right?

 

When testing this out by following the above test, I'm able to see that any changes in-app will overwrite the description sent across by the endpoint and this is currently the way the system works. 

 

This is because, if the user clicked on edit > remove the previous text, key it some new text > and save it > we wouldn't be able to know that the user would like to have the previous text and will only update the text accordingly to what it was saved.

 

That said, if you'd like to keep track of what are the engagements that has been modified, I'd suggest for you to look at the HubSpot get recent engagements api.

 

Hope this helps and do let me know if we're of a different page! I'm happy to help clarify things further.

Highlighted
Occasional Contributor

Hi Wendy,

 

Thanks for answering.

 

The steps are wrong:

 

Just to clarify the step that you took here:

1. You use the HubSpot create an engagement api to create a call engagement with e.g. metadata description: "test"

2. Next, the user may click on edit in-app and edit the description to example: "hello world"

3. Subsequently, you use the HubSpot update an engagement api to update the call engagement to e.g. "test 2"

4. The user did not refresh the page, and click save (he make de edit from the step 2).


- The user just see its information and not the other metadata that the api did.
- For some reason when you edit a description for an engagement and click save it overrites ALL the metadata but it should only edit the `metadata.body` (not the `metadata.fromNumber` or `metada.durationMilliseconds`). This behaviour does not make sense to me, the user just changed the body (the description) and not the other metadata and so why it is replaced?

Reply
0 Upvotes
Highlighted
Community Manager

Hi @danielgomez,

 

Thank you for the clarification.

 

These are the steps I took to try and reproduce things on my end:

1. I use the HubSpot create an engagement api to create a call engagement with the following POST body:

 

{
    "engagement": {
        "active": true,
        "ownerId": 1,
        "type": "CALL",
        "timestamp": 1409172644778
    },
    "associations": {
        "contactIds": [93801],
        "companyIds": [ ],
        "dealIds": [ ],
        "ownerIds": [ ]
    },
    "attachments": [
        {
            "id": 4241968539
        }
    ],
"metadata" : {
    "toNumber" : "5618769964",
    "fromNumber" : "(857) 829-5489",
    "status" : "COMPLETED",
    "durationMilliseconds" : 38000,
    "recordingUrl" : "https://api.twilio.com/2010-04-01/Accounts/AC890b8e6fbe0d989bb9158e26046a8dde/Recordings/RE3079ac919116b2d22",
    "body" : ""
}
}

2. Next, in-app I click on edit and edit the description to "hello world" (didn't hit save yet)

3. I then use the HubSpot update an engagement api to update the engagement using a PATCH request with the following body:

{
    "metadata": {
        "body": "test 2"
    }
}

4. Went back in-app, didn't refresh and click save

 

Now, I'm able to see that the description is currently "hello world" (and this is expected as the last change of the description was done through in-app with the description set as "hello world"). That said, I do not see any changes on the metadata.fromNumber or meta.durationMilliseconds.

 

You're right. If you're only updating the description, the only change will only be made on the description and not the other meta data. This is because the update engagement api is using a PATCH request.  

 

In this case, do you mind sharing with me the detailed steps you took (including the request url and request body you sent through)? As well as an example contact? 

 

If it's more comfortable for you, you can sent these information across via dm.

Reply
0 Upvotes
Highlighted
Occasional Contributor

@WendyGoh what do you mean by app? my users are using the front end https://app.hubspot.com and not the mobile app if that is what you mean.

 

Other question I have is... what is the attachment attribute you are setting in there?

Reply
0 Upvotes
Highlighted
Community Manager

Hi @danielgomez,

 

Pardon for the confusion. By app I mean in-app within your HubSpot portal which is the front end https://app.hubspot.com/ that you're referring to and not the HubSpot mobile app.

 

As for the attachment attribute, it is the file ID and you can get the files from the CMS files api here: List the metadata for all files | COS Files API

Reply
0 Upvotes
Highlighted
Occasional Contributor

# Try 1
1. I use the HubSpot create an engagement api to create a call engagement with the following POST body:


```
{
"engagement": {
"active": true,
"ownerId": 1,
"type": "CALL",
"timestamp": 1409172644778
},
"associations": {
"contactIds": [93801],
"companyIds": [ ],
"dealIds": [ ],
"ownerIds": [ ]
},
"attachments": [
{
"id": 4241968539
}
],
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 0
}
}
```
2. Next, in-app I click on edit and edit the description to "hello world" (didn't hit save yet)

3. I then use the HubSpot update an engagement api to update the engagement using a PATCH/PUT request with the following body:

```
{
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 38000,
"recordingUrl" : "https://api.twilio.com/2010-04-01/Accounts/AC890b8e6fbe0d989bb9158e26046a8dde/Recordings/RE3079ac919...",
"body" : ""
}
}
```

4. Went back in-app, didn't refresh and click save


# Try 2
1. I use the HubSpot create an engagement api to create a call engagement with the following POST body:


```
{
"engagement": {
"active": true,
"ownerId": 1,
"type": "CALL",
"timestamp": 1409172644778
},
"associations": {
"contactIds": [93801],
"companyIds": [ ],
"dealIds": [ ],
"ownerIds": [ ]
},
"attachments": [
{
"id": 4241968539
}
],
"metadata" : {
"status" : "COMPLETED"
}
}
```
2. Next, in-app I click on edit and edit the description to "hello world" (didn't hit save yet)

3. I then use the HubSpot update an engagement api to update the engagement using a PATCH/PUT request with the following body:

```
{
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 38000
}
}
```

4. Went back in-app, didn't refresh and click save
5. You can validate that the details tab does not contain the new duration.


*NOTE* also IM trying setting `metadata.disposition` in the step 3 and it also stays unupdated.

Reply
0 Upvotes
Highlighted
Occasional Contributor

I dont know how to format my answer right, so please check https://pastebin.com/7ttX7u91

 

@WendyGoh 

 

Try 1
I use the HubSpot create an engagement api to create a call engagement with the following POST body:
{
"engagement": {
"active": true,
"ownerId": 1,
"type": "CALL",
"timestamp": 1409172644778
},
"associations": {
"contactIds": [93801],
"companyIds": [ ],
"dealIds": [ ],
"ownerIds": [ ]
},
"attachments": [
{
"id": 4241968539
}
],
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 0
}
}
Next, in-app I click on edit and edit the description to “hello world” (didn’t hit save yet)

I then use the HubSpot update an engagement api to update the engagement using a PATCH/PUT request with the following body:

{
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 38000,
"body" : ""
}
}
Went back in-app, didn’t refresh and click save
Try 2
I use the HubSpot create an engagement api to create a call engagement with the following POST body:
{
"engagement": {
"active": true,
"ownerId": 1,
"type": "CALL",
"timestamp": 1409172644778
},
"associations": {
"contactIds": [93801],
"companyIds": [ ],
"dealIds": [ ],
"ownerIds": [ ]
},
"attachments": [
{
"id": 4241968539
}
],
"metadata" : {
"status" : "COMPLETED"
}
}
Next, in-app I click on edit and edit the description to “hello world” (didn’t hit save yet)

I then use the HubSpot update an engagement api to update the engagement using a PATCH/PUT request with the following body:

{
"metadata" : {
"toNumber" : "5618769964",
"fromNumber" : "(857) 829-5489",
"status" : "COMPLETED",
"durationMilliseconds" : 38000
}
}


Went back in-app, didn’t refresh and click save
You can validate that the details tab does not contain the new duration.


NOTE also IM trying setting metadata.disposition in the step 3 and it also stays unupdated.

Reply
0 Upvotes
Highlighted
Occasional Contributor

@WendyGoh Yeah but that's because you are not editing the fromNumber or any other fields in the update that is done while the user is editing the description.

Reply
0 Upvotes