ControlUrl - sending add-message is still causing ...
# support
e
Hello, I am using controlUrl to add messages to the assistants message history so it can track call time:
Copy code
if (currentDurationTotalSeconds > 30 && callData.checkCount % 6 === 0) { 
            console.log(`[CALL TRACKING] Adding elapsed time system message: ${elapsedMinutes}m ${elapsedSeconds}s`);
            await fetch(controlUrl, {
              method: 'POST',
              headers: { 'Content-Type': 'application/json' },
              body: JSON.stringify({
                type: 'add-message',
                message: {
                  role: 'assistant',
                  content: `[Call time: ${elapsedMinutes} minutes ${elapsedSeconds} seconds]`
                },
                // No response needed for this informational message
                triggerResponseEnabled: false 
              })
            });
          }
This is using the **add-message **command, not the say command Sometimes the assistant correctly does not say anything, but then sometimes the assistant will speak out the message that was added Could you assist please?
v
Hi there! 👋 I understand your frustration with the assistant sometimes speaking out messages that were added via the
add-message
command, even though you've set
triggerResponseEnabled
to false. I'm unable to pinpoint the exact cause in your specific implementation without more details, but I can definitely help with some potential causes and solutions based on similar issues other Vapi users have experienced. Based on the information I found, here are some potential causes and solutions: ## Potential Causes 1. **System Message Processing**: According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338730919904673853), the issue might stem from how system messages are processed in the conversation buffer and immediately sent to the LLM stream, potentially triggering a response even when they shouldn't. 2. **Message Role**: I notice you're using
role: 'assistant'
in your message. This might be causing the assistant to treat it as its own message that needs to be spoken. 3. **Configuration Interference**: Other settings in your assistant configuration might be overriding the
triggerResponseEnabled
flag. According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1330092161835733013), unexpected behavior can sometimes be caused by interference from other settings. 4. **Timing Issues**: The timing between message playback and action execution might not be properly synchronized, causing the assistant to speak unexpectedly. ## Potential Solutions 1. **Change Message Role**: Try changing the message role from
'assistant'
to `'system'`:
Copy code
javascript
message: {
  role: 'system',
  content: `[Call time: ${elapsedMinutes} minutes ${elapsedSeconds} seconds]`
},
2. **Use Mute Control**: If the assistant starts speaking unexpectedly, you could use the
mute-assistant
control to stop it: ```javascript vapi.send({ type: 'control',
control: 'mute-assistant' }) ``` 3. **Check Assistant Configuration**: Review your assistant's configuration settings, particularly
startSpeakingPlan
,
stopSpeakingPlan
, and
firstMessageMode
, as these can influence when the assistant speaks. 4. **Empty String for Request-Start**: According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333858668730515689), setting the request-start message to an empty string might prevent the default message from being used. 5. **Review Logs**: Check your server logs around the time when the issue occurs to see if there are any patterns or error messages that might provide more clues. Would you like me to elaborate on any of these potential solutions or suggest additional troubleshooting steps? Sources: - [Discord discussion about triggerResponseEnabled](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338730919904673853) - [Discord discussion about request-start messages](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333858668730515689) - [Discord discussion about configuration interference](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1330092161835733013)
e
call ID: 9d18746d-e43e-454e-b5b2-33d5685a17a6 When i tried using the system role, the system is not aware of the call time
It says in the docs that role using the system role will be unobtrusive and can be used for contextual updates. However, when I use the system role, the assistant is completely unaware of it https://cdn.discordapp.com/attachments/1361390885467848805/1361401035452710912/Screenshot_2025-04-14_at_19.00.43.png?ex=67fe9f04&is=67fd4d84&hm=787edde5559b61b4950feb92b66d962c1ebe2d56f9004b249b6e33b10c4d70eb&
cc @Shubham Bajaj
Now I tried it with using role = tool, and it seems to happen less frequently, but the assistant will still read out the tool message sometimes
s
Hi, Can you provide time duration in the recording when the issue occurred?
e
I just realized i think Claude is seeing the pattern of call times and also returning the call times in its response:
Copy code
call ID: 9d18746d-e43e-454e-b5b2-33d5685a17a6

16:51:08:372
[LOG]
Model output: [Call time:

16:51:08:373
[LOG]
Voice input: Any sensations, thoughts or emotions coming up? [Call time:

16:51:08:379
[LOG]
Model output: 1 minutes 53 seconds]
But if I use role=system , the assistant is unaware of the message See call id 570d0ef9-5c68-426a-ae28-68e901cb3126 The system message says the call time is 2 mins, but the assistant still says its 1 minute So I cant find any way of letting the assistant be aware of the call time. Can you please assist? Thank you https://cdn.discordapp.com/attachments/1361390885467848805/1362516483858759901/Screenshot_2025-04-17_at_21.51.57.png?ex=6802addc&is=68015c5c&hm=bac66bc925a1fb971b47a1467c9315bd1eb240b37abeefc2156f6f239f65d83b&
Hello - following up on this
k
Looking into it
e
thank you
s
Hey Ethan, try adding this into your prompt: The current date and time is: {{"now" | date: "%b %d, %Y, %I%M %p", "America/Chicago"}} Change America/Chicago based on your location. Than prompt it to remember the exact time the call started. If this doesn't work, I'll look into it. Let me know.
e
hey @masondoberstein0 Thanks for the suggestion. This will give it the start date, but how would the LLM know how long it's been since the call began?
ive tried asking the assistant and it doesnt know the call duration
s
checking if this is resolved/solved for you?
e
thanks @Shubham Bajaj no, still need help with this. It's very odd. Even when I use add-message with the user role, the assistant doesn't seem to be aware of it at all:
Copy code
// Send a message to the assistant about the client's local time
        await fetch(controlUrl, {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            type: 'add-message',
            message: {
              // Using 'user' role to mimic a system note injected into the conversation context
              role: 'user',
              content: `[Current time is ${userTime}]`
            },
            triggerResponseEnabled: false // Don't make the assistant respond to this
          })
        });
Call ID: 044adb5e-8efd-4a64-932a-0bb5945043ca https://cdn.discordapp.com/attachments/1361390885467848805/1365828659973460049/Screenshot_2025-04-27_at_00.13.43.png?ex=680eba90&is=680d6910&hm=4ab77e9600a6a46a2e1778a403cf1952b42e70dff9b0634d7e4efe495405f2ef&
s
Hey Ethan, the assistant never gets to know about time when you add it as a user role. It only uses the user messages to generate its next response. In case you want to pass some information, either pass it as role 'assistant' and try and make it work using it. If it doesn't work, then pass it as role'system'. Give her two to three test calls, try and let me know how it goes for you.
e
Hi Shubham I got it to work using role assistant , thank you. I'm wondering why it isnt able to see it if it's a system or user message though?
s
when pushing a message with role user, its consider as input to generate the next response. When pushing a message with role system or assistant, it's used to generate the next response.