# Injecting a message into live chat

**URL:** <https://community.hubspot.com/t/injecting-a-message-into-live-chat/139187>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [September 8, 2025, 6:52pm UTC](https://community.hubspot.com/t/injecting-a-message-into-live-chat/139187 "2025-09-08T18:52:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonK1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jasonk1/32/196052_2.png) [@JasonK1](https://community.hubspot.com/u/JasonK1)\
**Post date:** [September 8, 2025, 6:52pm UTC](https://community.hubspot.com/t/injecting-a-message-into-live-chat/139187/1 "2025-09-08T18:52:26Z")

</div>

I wrote a workflow to watch for stale live chats, closing them if they are stale for too long, and now I’m trying to figure out how to inject a message (e.g., “Are you still there?”, “I’m closing this chat. Please follow up if you would like further assistance.”)

I’m defining a message and posting it per how I understand the docs for the conversations API, which I believe is what I should use but I’m getting a 500 error. It makes me wonder if the API really allows for injecting messages into live chats.

```lia-code-sample
 message = {
 "type": "MESSAGE",
 "text": "Can I help you with any further questions?",
 "senderActorId": "A-[ACTORID]",
 "recipients": [
 {
 "deliveryIdentifier": {
 "type": "CHANNEL_SPECIFIC_OPAQUE_ID",
 "value": "[ID Taken from live chat conversation]",
 "recipientField": "TO"
 }
 }
 ],
 "channelId": channel_id,
 "channelAccountId": channel_account_id
 }

 message_string = json.dumps(message,indent=4)

 url2 = "https://api.hubapi.com/conversations/v3/conversations/threads/" + conversation_id + "/messages"

 response = requests.post(url=url2,headers=headers,data=message_string)

```

> **[Conversations API - HubSpot docs](https://developers.hubspot.com/docs/api-reference/legacy/conversations/guide)**
>
> Use the conversations API to manage inboxes, channels, threads, and messages.

I’m able to send a message to a conversation that’s not a live chat (i.e., that’s email using the above template) but I can’t get the message into a live chat.  
I would appreciate any pointers!

---

<div class="post-metadata">

**Author:** ![chighsmith](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@chighsmith](https://community.hubspot.com/u/chighsmith)\
**Post date:** [September 8, 2025, 9:28pm UTC](https://community.hubspot.com/t/injecting-a-message-into-live-chat/139187/2 "2025-09-08T21:28:07Z")

</div>

Hi @JasonK1,  
Thank you for posting to the Community!  
I’d like to tag in some of our Top Contributors to take a look here!  
Hi [@HubSpot\_Corey](https://community.hubspot.com/t5/user/viewprofilepage/user-id/580930) @Bortami and @WesQ Do you all have any tips for @JasonK1 on the above?  
Thank you!  
Cassie, Community Manager

---

<div class="post-metadata">

**Author:** ![JasonK1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jasonk1/32/196052_2.png) [@JasonK1](https://community.hubspot.com/u/JasonK1)\
**Post date:** [September 23, 2025, 3:44pm UTC](https://community.hubspot.com/t/injecting-a-message-into-live-chat/139187/3 "2025-09-23T15:44:54Z")

</div>

We figured this out. There was just a problem with the ‘recipients’. The ‘actorId’ was missing.

We ended up grabbing the ‘recipients’ information from the WELCOME\_MESSAGE that came back in the message history (a GET request to conversations/v3/conversations/threads/{threadId}/messages).
