Call engagement from and to

SycoLTH
Member

Hi,

I've an issue with how the engagements are shown, and I need to know if I'm using the api correctly:

OWNER:

$ curl -s -L "https://api.hubapi.com/owners/v2/owners/55175625?hapikey=asdasdads" | jq .
{
  "portalId": 8992011,
  "ownerId": 55175625,
  "type": "PERSON",
  "firstName": "Alberto",
  "lastName": "Test",
  "email": "atest@gmail.com",
  "createdAt": 1607641327793,
  "updatedAt": 1607965497215,
  "remoteList": [
    {
      "id": 39497428,
      "portalId": 8992011,
      "ownerId": 55175625,
      "remoteId": "12803963",
      "remoteType": "HUBSPOT",
      "active": true
    }
  ],
  "hasContactsAccess": false,
  "activeUserId": 12803963,
  "userIdIncludingInactive": 12803963,
  "activeSalesforceId": null,
  "isActive": true
}

CONTACT:

$ curl -s 'https://api.hubapi.com/crm/v3/objects/contacts/101?hapikey=asdasdasd' | jq .
{
  "id": "101",
  "properties": {
    "createdate": "2021-05-25T12:43:36.746Z",
    "email": "charles@manson.com",
    "firstname": "Charles",
    "hs_object_id": "101",
    "lastmodifieddate": "2021-05-25T13:14:55.447Z",
    "lastname": "Manson"
  },
  "createdAt": "2021-05-25T12:43:36.746Z",
  "updatedAt": "2021-05-25T13:14:55.447Z",
  "archived": false
}

 

The scenario is:

Contact Charles (+353123456789) makes an inbound call to the Owner Alberto (+35310000000), so the contact calls the agent.

Here's the curl to log the call:

$ curl -s -X POST -H 'Content-Type: application/json' --data '{
>   "engagement": {
>     "active": true,
>     "type": "CALL",
>     "ownerId": 55175625
>   },
>   "associations": {
>     "contactIds": [101],
>     "ownerIds": [55175625]
>   },
>   "metadata": {
>     "toNumber": "+35310000000",
>     "fromNumber": "+353123456789",
>     "status": "COMPLETED",
>     "durationMilliseconds": "29000",
>     "body": "N/A"
>   }
> }' "https://api.hubapi.com/engagements/v1/engagements?hapikey=asdasdasd" | jq .
{
  "associationCreateFailures": [],
  "engagement": {
    "id": 13550784638,
    "portalId": 8992011,
    "active": true,
    "createdAt": 1621948869265,
    "lastUpdated": 1621948869265,
    "ownerId": 55175625,
    "type": "CALL",
    "timestamp": 1621948869265,
    "allAccessibleTeamIds": [],
    "bodyPreview": "N/A",
    "queueMembershipIds": [],
    "bodyPreviewIsTruncated": false,
    "bodyPreviewHtml": "<html>\n <head></head>\n <body>\n N/A\n </body>\n</html>",
    "gdprDeleted": false
  },
  "associations": {
    "contactIds": [
      101
    ],
    "companyIds": [],
    "dealIds": [],
    "ownerIds": [
      55175625
    ],
    "workflowIds": [],
    "ticketIds": [],
    "contentIds": [],
    "quoteIds": []
  },
  "attachments": [],
  "metadata": {
    "toNumber": "+35310000000",
    "fromNumber": "+353123456789",
    "status": "COMPLETED",
    "durationMilliseconds": 29000,
    "body": "N/A"
  }
}

 

However the interface shows the call was made from the owner, with the contact phone number, to the owner phone number. What am I doing wrong?

SycoLTH_0-1621949006604.png

 

Thanks

 

7 Replies 7
dennisedson
Community Manager

@RBThomas seeing anything out of place here? 🤔

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
RBThomas
Top Contributor | Diamond Partner

I would try leaving the ownerIds attribute as a blank array and see if it fits your situation.

SycoLTH
Member

No,

$ curl -s -X POST -H 'Content-Type: application/json' --data '{
>   "engagement": {
>     "active": true,
>     "type": "CALL",
>     "ownerId": 55175625
>   },
>   "associations": {
>     "contactIds": [101]
>   },
>   "metadata": {
>     "toNumber": "+35310000000",
>     "fromNumber": "+353123456789",
>     "status": "COMPLETED",
>     "durationMilliseconds": "29000"
>   }
> }' "https://api.hubapi.com/engagements/v1/engagements?hapikey=asdasdasd" | jq .
{
  "associationCreateFailures": [],
  "engagement": {
    "id": 13566746919,
    "portalId": 8992011,
    "active": true,
    "createdAt": 1622018182667,
    "lastUpdated": 1622018182667,
    "ownerId": 55175625,
    "type": "CALL",
    "timestamp": 1622018182667,
    "allAccessibleTeamIds": [],
    "queueMembershipIds": [],
    "gdprDeleted": false
  },
  "associations": {
    "contactIds": [
      101
    ],
    "companyIds": [],
    "dealIds": [],
    "ownerIds": [],
    "workflowIds": [],
    "ticketIds": [],
    "contentIds": [],
    "quoteIds": []
  },
  "attachments": [],
  "metadata": {
    "toNumber": "+35310000000",
    "fromNumber": "+353123456789",
    "status": "COMPLETED",
    "durationMilliseconds": 29000
  }
}

without the ownerIds array it still shows the calls as this:

SycoLTH_0-1622018331915.png

Where From is "Owner Name (Contact Number)"

And To is "Owner Number"

 

So for callcenters that receive calls from customers, instead of calling customers, this is confusing.

Because calls are not made from the owner, they are received by the owner, or they are calls to the owner.

 

Thanks

0 Upvotes
webdew
Guide | Diamond Partner

Hi @SycoLTH ,

Pass below array with using api and create new engagement of call and assciate with contact, companies and deals.

<?php

$metadata = [
"toNumber" => @$val->metadata->toNumber,
"fromNumber" => @$val->metadata->fromNumber,
"externalId" => @$val->metadata->externalId,
"externalAccountId" => @$val->metadata->externalAccountId,
"calleeObjectType" => @$val->metadata->calleeObjectType,
"calleeObjectId" => @$val->metadata->calleeObjectId,
"status" => @$val->metadata->status,
"durationMilliseconds" => $dur,
"body" => $haptik_body,
"recordingUrl" => @$val->metadata->recordingUrl
];

$data_e = json_decode([
"engagement" => [
"active" => 1,
"type" => 'CALL',
"timestamp" => 1578327830000,
"createdAt" => 1578327830000,
"lastUpdated" => 1578327830000,
"createdBy" => 1578327830000,
"modifiedBy" => 1578327830000,
"ownerId" => 3672676,
"source" => 'source',
"sourceId" => 3565363,
"teamId" => 32763223,
"bodyPreview" => 'hello',
"bodyPreviewHtml" => 'hello'
],
"associations" => [
"contactIds"=> [],
"companyIds"=> [],
"ticketIds"=>[]
],
"metadata" => $metadata
]);

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

0 Upvotes
SycoLTH
Member

I'm sorry, but it doesn't help much,

where is this documented?

 

when I send this request I get back this:

{
  "status": "error",
  "message": "Unable to process JSON",
  "correlationId": "17629fa5-0b96-4b32-9c46-50370de20342"
}

 

0 Upvotes
RBThomas
Top Contributor | Diamond Partner

Based on @webdew's suggestion, have you tried filling out these fields in your metadata for the engagement?

 

$metadata = [
"toNumber" => @$val->metadata->toNumber,
"fromNumber" => @$val->metadata->fromNumber,
"externalId" => @$val->metadata->externalId,
"externalAccountId" => @$val->metadata->externalAccountId,
"calleeObjectType" => @$val->metadata->calleeObjectType,
"calleeObjectId" => @$val->metadata->calleeObjectId,
"status" => @$val->metadata->status,
"durationMilliseconds" => $dur,
"body" => $haptik_body,
"recordingUrl" => @$val->metadata->recordingUrl
];

 
Currently your metadata looks like this:

 

>     "toNumber": "+35310000000",
>     "fromNumber": "+353123456789",
>     "status": "COMPLETED",
>     "durationMilliseconds": "29000",
>     "body": "N/A"

 

SycoLTH
Member

Yes, but unfortunately I have to reiterate the question, where is documentation for these parameters?

All this is not in your documentation at https://legacydocs.hubspot.com/docs/methods/engagements/create_engagement 

 

What is externalId?

What is externalAccountId?

What is calleeObjectType? Should I use "contact" for this?

What is calleeObjectId? Should I use "101" (my test contact id) for this?

 

Thanks