Handling "opening chat event" and "threadId" on the frontend.

Hello.

Based on this reply:

https://community.hubspot.com/t5/APIs-Integrations/Init-a-human-agent-chat-passing-data-for-the-agent-to-be/m-p/1235399#M86218

I need to:

  • Init a chatbot to contact a human in my frontend.
  • Detect when the customer opens the chat.
  • Send to my backend the “threadId” and some text data.
  • The backend makes a POST to /conversations/v3/conversations/threads/{threadId}/messages to create a message with “type”: “INTERNAL”.
  • The agent sees in the Inbox a “note” on the conversation box, to have some extra context.

Now, my questions are:

  • How can I detect when the user opens the chatbox?
  • How can I get the “threadId” on the frontend?

I have been doing some black magic tricks to achieve it, but I need a stable solution.

Some recommendations on it?

Some documentation links, maybe?

Thanks!

Hello @MLara48!

Welcome back!

I hope you found the community helpful in your last post!

As for the threadid, I found these twos community posts here and here that you may find helpful! However, as for identifying when the chat widget was opened, I wasn’t able to find anything on this.
I’d like to tag in some of our Top Contributors to see if they have any experience with this!

@RubenBurdin, @SteveHTM, @TomM2

-- Do you have any suggestions for @MLara48 on this?

Sam, Community Manager

@MLara48 - my community colleague posted a pretty well structured reposnse in the previous posting, so I won’t try and cover the same ground. But it seems to me that the challenge posed in this question is somewhat odd - in the sense that you would never want a chat to be initiated by any agent other than the web site visitor.

But once the chat has been initiated, the conseverations object is set up and can be accessed by any back end agent/code - including access to the threadID of the dialog. You would need to be aware of the JSON structures retured by the API to access all the data, but your trigger would most likely be to start a Conversations workflow based on teh chat startup.

Hope this is helpful.

Steve