Engagements returned with HTML tags

OOneTalk_test
Participant

Engagements have HTML tags in their response (e.g. Note body). Is there some parameter or maybe alternative endpoint where we would be able retrieve them without tags? It is just that parsing them on our side would spend considerable amount of resources.

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hi @OOneTalk_test ,

 

Are you retrieving multiple engagements or a single engagement with each request?

For each engagement type, you need to access the 'metadata' object that is part of each result. I'll describe how you can access the plain text for each engagement type:

Email:
The plain text variant is available in the metadata.text object:

"metadata": {
    "from": {
        "email": "",
        "firstName": "",
        "lastName": ""
    },
    "to": [
        {
            "email": ""
        }
    ],
    "cc": [],
    "bcc": [],
    "sender": {},
    "subject": "",
    "html": "",
    "text": "",
    "trackerKey": "",
    "emailSendEventId": {},
    "validationSkipped": [],
    "pendingInlineImageIds": []
  }

 

Notes:

The plain text version is available in the metadata.body object:

"metadata": {
    "body": ""
}

 

Calls:
This result does not have a plain text version available in the metadata object. However, if the bodyPreviewIsTruncated value is false, you could use the bodyPreview:

{
    "engagement": {
        "id": 0,
        "portalId": 0,
        "active": true,
        "createdAt": 0,
        "lastUpdated": 0,
        "createdBy": 0,
        "modifiedBy": 0,
        "ownerId": 0,
        "type": "CALL",
        "timestamp": 0,
        "teamId": 0,
        "activityType": "",
        "allAccessibleTeamIds": [],
        "bodyPreview": "",
        "queueMembershipIds": [],
        "bodyPreviewIsTruncated": false,
        "bodyPreviewHtml": ""
    },
    "associations": {
        "contactIds": [],
        "companyIds": [],
        "dealIds": [],
        "ownerIds": [],
        "workflowIds": [],
        "ticketIds": [],
        "contentIds": [],
        "quoteIds": []
    },
    "attachments": [],
    "metadata": {
        "toNumber": "",
        "fromNumber": "",
        "status": "COMPLETED",
        "externalId": "",
        "durationMilliseconds": 0,
        "externalAccountId": "",
        "body": "",
        "disposition": "",
        "calleeObjectType": "",
        "calleeObjectId": ,
        "title": "",
        "source": "",
        "callsServiceCallId": 0
    }
  }

 

Tasks:
The same applies for tasks. There is no plain text version available, but if bodyPreviewIsTruncated is false, you can use the bodyPreview:

  "metadata": {
    "body": "",
    "status": "COMPLETED",
    "forObjectType": "OWNER",
    "subject": "",
    "taskType": "TODO",
    "reminders": [],
    "sendDefaultReminder": true,
    "priority": "NONE",
    "isAllDay": false,
    "completionDate": 0
  }

 

Meeting:
You can access the plain text version in the metadata.body:

  "metadata": {
    "startTime": 0,
    "endTime": 0,
    "title": "",
    "body": "",
    "preMeetingProspectReminders": []
  }


I could be mistaken here, but it is possible to retrieve the plain text version for each engagement type except calls and tasks. If the bodyPreviewIsTruncated you can use the bodyPreview but if that one is set to true, you would still need some 'striptags' functionality in your code.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

4 Replies 4
Teun
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hi @OOneTalk_test ,

 

Are you retrieving multiple engagements or a single engagement with each request?

For each engagement type, you need to access the 'metadata' object that is part of each result. I'll describe how you can access the plain text for each engagement type:

Email:
The plain text variant is available in the metadata.text object:

"metadata": {
    "from": {
        "email": "",
        "firstName": "",
        "lastName": ""
    },
    "to": [
        {
            "email": ""
        }
    ],
    "cc": [],
    "bcc": [],
    "sender": {},
    "subject": "",
    "html": "",
    "text": "",
    "trackerKey": "",
    "emailSendEventId": {},
    "validationSkipped": [],
    "pendingInlineImageIds": []
  }

 

Notes:

The plain text version is available in the metadata.body object:

"metadata": {
    "body": ""
}

 

Calls:
This result does not have a plain text version available in the metadata object. However, if the bodyPreviewIsTruncated value is false, you could use the bodyPreview:

{
    "engagement": {
        "id": 0,
        "portalId": 0,
        "active": true,
        "createdAt": 0,
        "lastUpdated": 0,
        "createdBy": 0,
        "modifiedBy": 0,
        "ownerId": 0,
        "type": "CALL",
        "timestamp": 0,
        "teamId": 0,
        "activityType": "",
        "allAccessibleTeamIds": [],
        "bodyPreview": "",
        "queueMembershipIds": [],
        "bodyPreviewIsTruncated": false,
        "bodyPreviewHtml": ""
    },
    "associations": {
        "contactIds": [],
        "companyIds": [],
        "dealIds": [],
        "ownerIds": [],
        "workflowIds": [],
        "ticketIds": [],
        "contentIds": [],
        "quoteIds": []
    },
    "attachments": [],
    "metadata": {
        "toNumber": "",
        "fromNumber": "",
        "status": "COMPLETED",
        "externalId": "",
        "durationMilliseconds": 0,
        "externalAccountId": "",
        "body": "",
        "disposition": "",
        "calleeObjectType": "",
        "calleeObjectId": ,
        "title": "",
        "source": "",
        "callsServiceCallId": 0
    }
  }

 

Tasks:
The same applies for tasks. There is no plain text version available, but if bodyPreviewIsTruncated is false, you can use the bodyPreview:

  "metadata": {
    "body": "",
    "status": "COMPLETED",
    "forObjectType": "OWNER",
    "subject": "",
    "taskType": "TODO",
    "reminders": [],
    "sendDefaultReminder": true,
    "priority": "NONE",
    "isAllDay": false,
    "completionDate": 0
  }

 

Meeting:
You can access the plain text version in the metadata.body:

  "metadata": {
    "startTime": 0,
    "endTime": 0,
    "title": "",
    "body": "",
    "preMeetingProspectReminders": []
  }


I could be mistaken here, but it is possible to retrieve the plain text version for each engagement type except calls and tasks. If the bodyPreviewIsTruncated you can use the bodyPreview but if that one is set to true, you would still need some 'striptags' functionality in your code.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


OOneTalk_test
Participant

Thank you! Works great.

Teun
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hi @OOneTalk_test ,

 

What type of engagements are you retrieving? Depending on the 'TYPE' you have several ways to retrieve the plain text variant.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


OOneTalk_test
Participant

Hi Teun,

We are retrieving Notes, Tasks, Calls and also plan to retrieve Meetings in future (so basically we are interested in everything except for Emails).

0 Upvotes