Passing variables in Squads
# support
d
Hi, is there any possibility of passing small, selected parts of data between assistants in squads? Something similar to “Gather” block in workflows would be ideal. I know there’s conversation history in Squads, but it doesn’t work in my use case. Using dynamic variables crossed my mind, but I have no idea on how to implement it into squads. Let me give some context: I’m building an inbound caller for dental practices. I use the first assistant in squad (AD-start) to classify whether the caller wants to book/reschedule/cancel an appointment. When it takes the scheduling path, the next assistant (AD-W8) is analyzing the scheduling reason (if provided) and picking the appropriate field of dentistry (and then tranfers the call further). But here’s the problem: if I provide the scheduling reason in the beginning (e.g. I begin with “I would like to book a follow-up visit”, while the call is still hold by "AD-start"), the next assistant "AD-W8" has trouble in getting the booking reason from the conversation memory. It happens randomly - one time it succeeds, one time it doesn't. I tested a different approach via text in make.com - instead of inputting conversation memory into "AD-W8" assistant, I injected it with a variable “booking_reason” (it contained just a booking reason, e.g. "follow-up visit") - and the "AD-W8" assistant worked perfectly fine. Also, it isn’t the system prompt’s fault - when I DON’T provide the booking reason in the beginning of the call (e.g. if I begin with “I would like to schedule an appointment”), and I teel the booking reason after the second assistant asks me, it always. recongises the booking reason I also tried to prompt the LLM in many different ways to extract the booking reason from the conversation history, but it still remained random. Only minimizing the conext data to “booking_reason” solved the issue. https://cdn.discordapp.com/attachments/1360718893542539465/1360718893907181568/image.png?ex=67fc23b9&is=67fad239&hm=51aaa16b8ae5c1b9367a429cac6ecd46215ea11792912077625fbf49e0eb9f4b&
v
Hi there! 👋 I understand your frustration with the inconsistent behavior when trying to pass the booking reason between assistants in your dental practice call flow. I'm unable to provide information about a direct "Gather" block equivalent in Squads, but I can definitely help with several methods to reliably pass variables between assistants! Based on your use case, here are some approaches that should work better than relying on conversation history: ### 1. Using
membersOverrides
with a Transient Squad This is likely the most reliable method for your use case:
Copy code
javascript
// 1. Get your squad configuration
const squad = {...squadConfig}

// 2. Create transient squad configuration with overrides
const callPayload = {
  squad: {
    ...squad,
    membersOverrides: {
      variableValues: {
        booking_reason: "follow-up visit"
      }
    }
  }
};
// 3. Make the call with the transient squad
// use create call API or SDK
According to the [Discord discussion](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342518227816808449), this workaround is necessary because "membersOverrides are not currently supported with the squadID." ### 2. Updating
variableValues
Mid-Call Your first assistant could update the call data using a PATCH request: 1. First assistant (AD-start) talks to the caller and gets the booking reason 2. AD-start calls a tool that makes a
PATCH /call/:id
request to update
membersOverrides.variableValues
3. AD-start transfers to AD-W8 4. AD-W8 can reference the variables This is documented in a [Discord thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329772290497318973), though there were some reports of inconsistency. ### 3. Using Background Messages You could have your first assistant silently update the chat history with structured data: ```javascript vapi.send({ type: "add-message", role: "system",
content: JSON.stringify({ booking_reason: "follow-up visit" }) });
Copy code
According to the [background messages documentation](https://docs.vapi.ai/assistants/background-messages), this allows you to inject information that subsequent assistants can access.

### 4. Setting Assistant-Specific Overrides

You can use `members[n].assistantOverrides` to set variables for specific assistants:

```javascript
{
  "squad": {
    "members": [
      {
        "assistantId": "ad-start-id",
        "assistantOverrides": { ... }
      },
      {
        "assistantId": "ad-w8-id",
        "assistantOverrides": {
          "variableValues": {
            "booking_reason": "follow-up visit"
          }
        }
      }
    ]
  }
}
This approach is mentioned in the [Squads API reference](https://docs.vapi.ai/api-reference/squads/create). Since you mentioned that injecting the variable "booking_reason" worked perfectly in your make.com tests, I'd recommend trying the transient squad approach first, as it seems most aligned with your successful test case. Would you like more details on any of these approaches or help with implementation? Sources: - [Discord discussion on membersOverrides](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342518227816808449) - [Discord thread on updating variableValues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1329772290497318973) - [Background messages documentation](https://docs.vapi.ai/assistants/background-messages) - [Squads API reference](https://docs.vapi.ai/api-reference/squads/create)
k
checking if this is resolved/solved for you?
d
Not yet
a
Just got this working. I created a tool with the variables I want and assign it to all assistants. Then in the squad assistants, I have something like this > # Customer Information > Customer Name: {{name}} > Customer Email: {{email}} > > # Rules > Before transfering call to another assistant, call [squad_function_tool] to pass the customer's info to the other assistant.
d
I created that tool, it runs and extracts booking_reason before transitioning to the next assistant. I added "assistantOverrides" with "variableValues", but now I don't know what to how to pass the variable from that tool as a value of the variable in "variableValues". I just wrote that webhook variable's name, but it doesn't inject any information. Is that the way you meant to do it?
a
are you doing this with webhooks, that's when you ise the assistantOverridesa and variableValues? You only need WH if you are getting new data. In my case I do the intial WH to get the info from the CRM and then just pass it from assistant to assistant using the tool.
d
Alright, you say you get the info from the CRM, do you mean that you do the assistantOverrides before the call starts? What I need for my usecase, is updating the squad members mid-call. Today I created a scenario, in which the "AD-start" determines the "booking_reason" and calls a tool, which sends it via webhook to make.com. After that webhook I do a HTTP PATCH request, which has "membersOverrides" for the whole squad, and in the overrides in "variableValues" I inject "booking_reason". I tested it today, that PATCH request is done before the call gets transitioned to the second assistant, but the second assistant isn't speaking with the data it was updated with. It speaks with these data only after starting a new call.
@User @Shubham Bajaj Could you please take a look at this? It's really important for me to get this working.
a
I think you may have the same issue I did. Check this out.. I had to add assistantOverride not membersOverride, but IDK if that's the way it is supposed to work. Per the Vapi guys, it shoudn't work that way, but that's the only way I got it to work... https://discord.com/channels/1211482211119796234/1359698337095483499
d
Thanks, man, I'll check this chat out. Also, would you mind if we chatted about that variable passing further in the DMs?
3 Views