# Execute custom JS event based on Chatbot response

**URL:** <https://community.hubspot.com/t/execute-custom-js-event-based-on-chatbot-response/22972>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [July 16, 2020, 2:20pm UTC](https://community.hubspot.com/t/execute-custom-js-event-based-on-chatbot-response/22972 "2020-07-16T14:20:02Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![awright415](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/awright415/32/70551_2.png) [@awright415](https://community.hubspot.com/u/awright415)\
**Post date:** [September 10, 2020, 11:07pm UTC](https://community.hubspot.com/t/execute-custom-js-event-based-on-chatbot-response/22972/3 "2020-09-10T23:07:24Z")

</div>

I was hoping for similar functionality. So far, the only idea I’ve come up with (but would require a _heavy_ lift) is having some sort of parallel system that can communicate w/ the browser via websockets.

A code snippet or webhook chatbot step would pass along info to that second system, which could then relay events back to the browser.

But you’d need a good correlation ID to pass between the systems. The chat widget SDK _does_ give you a conversation ID that you can listen for, but it doesn’t appear conversation ID is passed to either code snippet or webhook actions. What _is_ passed to those actions is a contact VID for known contacts. So, if your use case doesn’t need to support anonymous visitors, that might be your best bet.

Otherwise, I think we’re left with lobbying Hubspot to either: 1) include conversation ID in the webhook and/or code snippet payloads, or 2) let us set custom state for the conversation from the client side that could be passed along to the appropriate chatbot actions.

---

_[View the full topic](https://community.hubspot.com/t/execute-custom-js-event-based-on-chatbot-response/22972)._
