.send() system messages have no effect
# support
n
I'm trying to have my agent professionally wrap up the call once its reaching its time limit. In my call logs I can see that new system messages are being added through .send() successfully but they seem to have no effect on the model output at all. https://cdn.discordapp.com/attachments/1348419796177256538/1348419796429176924/image.png?ex=67cf654b&is=67ce13cb&hm=5984f5b0927c8b17db340a18ab8d5f36b2506d84096f1ec08f7668e634e6fa60& https://cdn.discordapp.com/attachments/1348419796177256538/1348419796726976625/image.png?ex=67cf654b&is=67ce13cb&hm=2b4f6b8c099099506640df6f29b72e5f0ec807b76b49161ad67db4451102eb9d&
v
I see the issue you're experiencing with system messages not affecting your agent's behavior. Based on the documentation, there are a couple of key points to address: 1. **System Message Configuration**: When using
.send()
with system messages, you need to ensure the
triggerResponseEnabled
flag is set to
true
(which is the default). If it's set to
false
, the message will be added to the context but won't trigger a response from the AI assistant.
Copy code
javascript
vapi.send({
  type: 'add-message',
  message: {
    role: 'system',
    content: 'There is 1 minute remaining. End the call professionally...'
  },
  triggerResponseEnabled: true  // Make sure this is true
});
2. **End Call Implementation**: For professionally ending calls, you have a few options: a) Use the
say
method with `endCallAfterSpoken`:
Copy code
javascript
   vapi.say("Thank you for trying our demo. To build your own AI agent, please create an account!", true);
b) Send a message followed by an end-call command:
Copy code
javascript
   // First send closing remarks
   vapi.send({
     type: "add-message",
     message: {
       role: "assistant",
       content: "Thank you for your time and for trying the demo..."
     },
     triggerResponseEnabled: true
   });
   
   // Then end the call (with a slight delay if needed)
   setTimeout(() => {
     vapi.send({
       type: "end-call"
     });
   }, 2000);
3. **Ensure
endCall
tool is configured**: Make sure the
endCall
tool is included in your assistant's configuration:
Copy code
json
   {
     "model": {
       "provider": "openai",
       "model": "gpt-3.5-turbo",
       "tools": [
         {
           "type": "endCall"
         }
       ]
     }
   }
From your logs, it appears the system message is being added but the model continues with its regular conversation flow instead of acknowledging the time limit instruction. This suggests the model might not be processing the system message as an immediate directive. Sources: - [Discord Message](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338730919904673853) - [Discord Message](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343304419210694656) - [Vapi Documentation](https://docs.vapi.ai/assistants/background-messages) - [Vapi Documentation](https://docs.vapi.ai/tools/default-tools) - [Vapi Documentation](https://docs.vapi.ai/sdk/web)
n
@Vapi Support Bot "message": "Object literal may only specify known properties, and 'triggerResponseEnabled' does not exist in type 'AddMessageMessage'.",
k
Hey! To help track down this issue, could you share: - The call ID This would really help us figure out what went wrong!
g
@nearLucid Were you able to resolve this issue? I'm also trying to implement the same feature for wrapping up the call once its reaches the time limit (this can be dynamic in my use case)
@Shubham Bajaj why is call id required? wouldn't it be different for every use case
n
Yes DM me
Actually I can just describe it here
g
@nearLucid ^
n
i tested a bit with the different roles you can throw in and assistant is the only one that works
for my use case my calls are a set duration so once the timer passes a certain threshold i listen for the user to start talking and use .send to let the agent know to wrap things up
have to listen for the user to talk bc if you run .send while the agent is talking, it gets interrupted and kinda bugs out for a sec
this is the smoothest i've gotten it to be
still wish there was a way to do it from backend
g
@nearLucid do you have some sample code snippet/demo that you can share?
> have to listen for the user to talk bc if you run .send while the agent is talking, it gets interrupted and kinda bugs out for a sec In my case, it corrupts entirely, seems like it gets stuck in a never ending loop
> still wish there was a way to do it from backend yeah, this is definitely a use case vapi team should implement.
n
sorry, cant share specific code but vapi uses daily.js so you should def look at their documentation for how to listen to the audio stream
g
@nearLucid This helped but if I ask the agent to start the call again, then it forgets the time limit instruction and starts the call all over.
Do you've any workaround for this?
Also, while experimenting I noticed that the agent is not always informing the user about the time limit.
@nearLucid have you run into these issues before? If so, any suggestions on how to fix them?
s
@godlike Just want you to check your current progress and if you could share the call ID, I can track down what exactly you're trying to get done and how it's going for you.
g
@Shubham Bajaj
aa929ab9-e91a-4bf7-b17a-0db02355b6c5
k
Hey, can you share the code snippet on how you're sending the messages? Looking at the logs, I can see that most of the messages are empty and eventually get ignored. šŸ”µ 17:07:53:293 Live Call Manager Control Message Received But Empty. Ignoring... {}