Sometimes we get empty content in the conversation...
# support
a
When we get a conversation update from VAPI, we are storing it in an ARRAY without pre processing, so when we do the same, some times we get conversation message object as follows,
Copy code
{
  "role": "assistant",
  "content": "",
  "_id": "666712f04609341fdee871a8"
}
The content is empty, can we stop sending the empty content conversation update?
v
message has been deleted
@Anil Certainly! To avoid receiving conversation updates with empty content, you can implement a filter on the client side that checks the
content
field of each message. If the
content
is empty, you can simply ignore that update and not store it in your array. Here's a basic example of how you could modify the message event handler to achieve this:
Copy code
javascript
vapi.on("message", (msg) => {
  // Check if the message is a transcript and if the content is not empty
  if (msg.type === "transcript" && msg.content !== "") {
    // Store the message in the array since the content is not empty
    // Your array storing logic goes here
  }
});
By adding this condition, you ensure that only messages with non-empty content are processed and stored. If you need any further assistance or have additional questions, please feel free to ask!
You can continue this conversation by mentioning me in the message.
a
Sure, definately we can add that, but is there any ways you guys can do it?
s
It is to prevent websocket from being closed.