APIs & Integrations

EstebanCastro
Participant

Respond to a ticket conversation via API

SOLVE

Hello everybody!

I'm working with the Hubspot API to create a website where you can create tickets using forms and see their engagements.

 

1) Send ticket form via javascript form.

Captura de pantalla 2021-05-07 a las 14.57.02.png

 

2) Read tickets

 

curl --location --request POST 'https://api.hubapi.com/crm/v3/objects/tickets/search?hapikey=demo' \
--header 'content-type: application/json' \
--header 'Cookie: __cfduid=defdf8f9d3ce28c171639a737aecf19991617882670' \
--data-raw '{
  "filterGroups": [
    {
      "filters": [
        {
            "propertyName": "associations.contact",
            "operator": "EQ",
            "value": "344930714"
        }        
      ]
    }
  ],
  "sorts": [
      {
        "propertyName": "createdate",
        "direction": "DESCENDING"
      }
  ],
  "properties": [
  ],
  "limit": 10,
  "after": 0
}'

 

 

3) Read engagements

 

curl --location --request GET 'https://api.hubapi.com/engagements/v1/engagements/13073367213?hapikey=demo' \
--header 'Cookie: __cfduid=defdf8f9d3ce28c171639a737aecf19991617882670'

 

 

Everything that is answered from the hubspot CRM in the conversation appears on my website correctly.

 

Captura de pantalla 2021-05-07 a las 15.00.19.png

 

And if you reply by mail (gmail) to this message, it appears correctly as engagement and as a response in the conversation

 

Captura de pantalla 2021-05-07 a las 15.01.18.png

What I want now is to respond to this conversation via API as if it were answered by email and that it appeared in the Hubspot CRM conversation

 

1) Create engagement vía API.

 

curl --location --request POST 'https://api.hubapi.com/engagements/v1/engagements?hapikey=demo' \
--header 'Content-Type: application/json' \
--header 'Cookie: __cfduid=defdf8f9d3ce28c171639a737aecf19991617882670' \
--data-raw '{
    "engagement": {
        "active": true,
        "ownerId": 70505496,
        "type": "EMAIL",
        "timestamp": 1620297687888,
        "source": "CONVERSATIONS"
    },
    "associations": {
        "contactIds": [101],
        "companyIds": [ ],
        "dealIds": [ ],
        "ownerIds": [ ],
		"ticketIds":[400047780 ]
    },
    "attachments": [
    ],
    "metadata": {
        "from": {
        "email": "email@domain.com",
        "firstName": "First",
        "lastName": "Last"
        },
        "to": [
        {
            "raw": "support@19678522.hubspot-inbox.com",
            "email": "support@19678522.hubspot-inbox.com"
        }
        ],
        "cc": [],
        "bcc": [],
        "subject": "Re: Prueba de texto",
        "html": "<div>aaaa</div>",
        "text": "aaaaa"
    }
}'

 

 

With this endpoint, the engagement is correctly created but it does NOT appear as a response in the Husbpot CRM chain (CONVERSATIONS).

Captura de pantalla 2021-05-07 a las 15.04.24.png

However, it does appear in the Emails and Activity sections of the ticket.

Captura de pantalla 2021-05-07 a las 15.07.12.png

Is there any way to create an engagement as a response to the conversation chain as if it were answered by Email and it appeared in the Conversations section of the Hubspot CRM?

 

Thanks and sorry for my english!

1 Accepted solution
tominal
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Respond to a ticket conversation via API

SOLVE

This is an interesting one. While I don't think it's possible through the API, that doesn't mean it's not impossible to keep it in that single engagement.

You could update ( to append to ) that engagement's HTML body with the reply's HTML to make it look like a thread. Does that make sense? It sounds better in my head but it may not accomplish the exact look of what Esteban is looking for.

Hope that helps!

View solution in original post

AGarcia8
Participant

Respond to a ticket conversation via API

SOLVE

Same issue here.

0 Upvotes
EstebanCastro
Participant

Respond to a ticket conversation via API

SOLVE

Thanks for the response and ideas.

I think they serve me for what I want to do.

Hope you keep improving the API. Nice job.

 

Greetings

dennisedson
Community Manager
Community Manager

Respond to a ticket conversation via API

SOLVE

@tominal , do you have any advice here?

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
tominal
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Respond to a ticket conversation via API

SOLVE

This is an interesting one. While I don't think it's possible through the API, that doesn't mean it's not impossible to keep it in that single engagement.

You could update ( to append to ) that engagement's HTML body with the reply's HTML to make it look like a thread. Does that make sense? It sounds better in my head but it may not accomplish the exact look of what Esteban is looking for.

Hope that helps!