Live Call Control and variables
# support
a
I was told during the office hour to use LCC to get caller's name and other info using the caller's phone number and I was able to use "say" and "add-message". The "add-message" without saying it... has the info that I would expect to get into some existing variables. It worked, somehow, for this call: call_oE6Mpn9DGqO94v6GO7HxUIRX but not for this call: call_i5IBcZxv8GX9evzK9uRFJDt3 Any ideas why and/or how to address this? https://cdn.discordapp.com/attachments/1359698337095483499/1359698337514651779/image.png?ex=67f86d41&is=67f71bc1&hm=b348f275a641dea395a31e64683db10fca6a62ea436c7dbb98a5ad435b868876& https://cdn.discordapp.com/attachments/1359698337095483499/1359698338156515429/image.png?ex=67f86d41&is=67f71bc1&hm=87642179e6fdb9924c579f00a74c0895b94c0a591dae58f91e0fbac79c1383e1&
v
Hey there! 👋 I can see you're having an issue with the "add-message" function working inconsistently between two different calls. While I can't pinpoint the exact cause without more details, I can definitely help explain some potential reasons and solutions. I notice that in the first call (call_oE6Mpn9DGqO94v6GO7HxUIRX) your function arguments contain user information (Email and Name), while in the second call (call_i5IBcZxv8GX9evzK9uRFJDt3) the argument is just a JSON with "Day": "Friday". This difference might be significant. ## Potential causes for the inconsistency: 1. **Caching issues**: According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342338583721414677), there's a known bug where the first message audio doesn't update as expected due to caching problems. This could affect how variables are processed. 2. **`triggerResponseEnabled` flag**: The system messages added via
add-message
are processed in the conversation buffer and sent to the LLM stream. If the
triggerResponseEnabled
flag is not set correctly, it might cause unexpected behavior. As noted in [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338730919904673853), this flag controls whether a message should trigger an LLM response. 3. **Different call configurations**: The two calls might have different configurations for monitoring. For Live Call Control to work properly, both
listenEnabled
and
controlEnabled
need to be set to
true
in the
monitorPlan
. ## Possible solutions: 1. **Check your message format**: Ensure your
add-message
call includes the correct role and content format:
Copy code
javascript
{
  type: 'add-message',
  message: {
    role: 'system',  // or 'tool' depending on your use case
    content: 'Your content here'
  },
  triggerResponseEnabled: false  // Set to false to update silently
}
2. **Use variable substitution**: According to [Discord discussions](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343457322072145950), you can use variable substitution in your system prompts:
Copy code
javascript
const assistant = {
  model: {
    messages: [
      {
        role: 'system',
        content: 'Current user: {{userName}}'
      }
    ]
  }
};

// Update variables
const variables = {
  userName: 'Alex'
};
3. **Check for microphone permissions**: If microphone permission is not granted within 10 seconds, the call might end prematurely, affecting the
add-message
function. Would you be able to share more details about how you're implementing the
add-message
function in your code? That might help narrow down the issue further. Sources: - [Discord discussions on add-message behavior](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1338730919904673853) - [Discord discussions on caching issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342338583721414677) - [Discord discussions on variable substitution](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1343457322072145950)
a
These are two calls back to back using the same setup, so its not a config issue. Maybe.... the cache issue could be the problem, but I'm really looking for a way to get the info into the variables that get inserted into the message.
Hi @Shubham Bajaj. I'm following your instructions on this post: https://discord.com/channels/1211482211119796234/1353047867438137505/1353906866932944907 I removed the squad from my number and setting up the assistant-request, but does that work to set up a squad? Is setting up a squad any differnent than setting up the id of the squad vs the assistant id?
hmmm. yeah... doesn't look like simply using the squad id as the assistant id works. any suggestions?
s
Hey Alex, could you share the response you're sending back to the assistant request or any Call ID related to it? I can take a look at the logs to see what might've gone wrong for you.
a
@Shubham Bajaj with your help on the OH yesterday, I can now send the squad ID and assistant overrides. See below. Howerver the overrides are "global", meaning that I can't send the variableValues to all of the agents in the squad. Maybe I don't need to send it to all of them, but what I can't figure out how to or even if I can, if the call is transfered to another assistant in the squad, how can these (and additonal) variableValues be passed to the other agent on a tranfser? 06e45ca6-2b0e-4634-a10b-dd1a8833e374 > { > "squadId": "c6123052-1b5c-498e-9527-7aa4de11747f", > "assistantId": "be5f63e2-2177-4280-9502-45c0841c22dd", > "assistantOverrides": > { > "firstMessage" : "Hi {{ $json.Name }}. Nice to talk to you again.", > "variableValues": > { > "Email": "{{ $json.Email }}", > "Name": "{{ $json.Name }}" > } > } > }
s
Hey Alex, you can use either a Squad ID or Assistant ID. You must use one of them. The second thing is to use Assistant Overwrites with the squad. You can't use Squad ID and Assistant Overwrites. Instead, use a Transient Squad and pass member overwrites to it, which will apply to each assistant in the squad. I suggest you look at the Create Call API in the docs page. You can pass member overwrites when creating a Transient Squad. 
Copy code
curl -X POST "https://api.vapi.ai/call" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "squad": {
      "name": "Transient Squad Example",
      "members": [
        {
          "assistant": {
            "name": "First Assistant",
            "firstMessage": "Hello, how can I help you today?",
            "model": {
              "provider": "openai",
              "model": "gpt-4"
            },
            "voice": {
              "provider": "vapi",
              "voiceId": "echo"
            }
          }
        },
        {
          "assistant": {
            "name": "Second Assistant",
            "firstMessage": "I'm the second assistant, how can I assist?",
            "model": {
              "provider": "openai",
              "model": "gpt-4"
            },
            "voice": {
              "provider": "vapi",
              "voiceId": "nova"
            }
          }
        }
      ],
      "membersOverrides": {
        "firstMessage": "Hello, this is an overridden first message for all assistants.",
        "voice": {
          "provider": "vapi",
          "voiceId": "alloy"
        }
      }
    },
    "customer": {
      "number": "+1234567890",
      "name": "John Doe"
    },
    "phoneNumber": {
      "number": "+0987654321"
    }
  }'
Let me know if you require further help.
a
Hmmmm.. I'm doing this for Inbound. So when a call comes in, I want t pull in some CRM data. I watched this, but again, he's doing it with just an Assistant, and I need a squad; to separate items that the assistant covers - makes the prompt easier to work with.

https://www.youtube.com/watch?v=LAvyRKK2fhAâ–¾

s
checking if this is resolved/solved for you?
a
no. I'm still trying to figure out how to pass the data pulled at the time of the assistant-request to the rest of the agents in the squad. It is working if using just a single assistant, but can't seem to be able to get it working with squads.
@Kings_big💫 @Shubham Bajaj ok... finally figured it out... Using the assistant-request, I send back the squad id, its members and memeber overrides. I also MUST send assistantOverrides for it all to work. Without, the initial reply doesn't have access to the variables and neitehr do the rest of the agents in the squad. Can you please confirm this is WAD? > { > "squadId": "2d3245d3-c422-42e0-b6eb-5f1a8b110656", > "assistantOverrides": { > "variableValues": { > "email": "johnwick@abcstudios.com", > "name": "William" > } > }, > "members": [ > { > "assistantId": "d534e93b-8c8d-4fb5-886d-efdc94df488b" > }, > { > "assistantId": "3c68ee5d-b8b4-4e92-987f-23cfc71de311" > }, > { > "assistantId": "473b14f4-279e-4d55-b7d8-a85e909e396b" > } > ], > "membersOverrides": { > "variableValues": { > "email": "johnwick@abcstudios.com", > "name": "William" > } > } > }
s
a
Hi. 7f17e4ae-d835-461d-87dc-a397097172d6 2184e1fc-9eb6-4295-8434-a97eb9a5ed1c failed to get my name when using the structure you provided, squad, memebers, memberoverrides. I put back the assistantoverrides and it worked as i expected, knew my name and each transfer answered with a personalized message. ae5c9930-19a6-457f-82cf-0d7c2c49a2b7 so it looks like the assistantOverrides is required. I then removed the memeberOverrides and it also worked as expected - got all personalized greetings on the main call and with each transfer. So it looks like it needs assistantOverrides and members, but not memebrOverrides. Call: 82c8f50e-002b-4086-8132-1e63a497e92c
It is now working as I would expect, but would like to know if this is the expected behaviour so if I start using this, it won't break in the future, since the suggested approach doesn't seem to achieve what we think it should.
s
It will not break now.
2 Views