Distinguishing Inbound vs Outbound Calls in Vapi
# support
h
@Vapi @Vapi Support Bot I’m working on call flows in Vapi and want the agent to greet differently depending on whether the call is outbound or inbound. I tried using the
call.type
variable, but it doesn’t seem to distinguish properly between inbound and outbound calls. Here’s the snippet I’m using: {% if call.type == "outboundPhoneCall" %} - "Hi {{firstName}}, this is Lexi with NEXA Mortgage. We helped with your last FHA or VA home loan, and I'm reaching out as part of your quarterly mortgage review. I hope you're having a great day." {% elsif call.type == "inboundPhoneCall" %} - "Hi {{firstName}}, this is Lexi with NEXA Mortgage. Thanks for calling! You’ve been invited to learn more about our Quarterly Mortgage Review." {% endif %} How can I correctly distinguish between inbound and outbound calls in Vapi so the greeting script triggers appropriately?
c
Hi, The variable
{{call.type}}
is not available in Vapi’s template system, so it cannot be used directly in system prompts or first messages. Recommended solution: Pass a custom variable using
assistantOverrides.variableValues
, then reference it in your prompt. For outbound calls (via API):
Copy code
POST /call/phone
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "callDirection": "outbound",
      "firstName": "John"
    }
  },
  "phoneNumberId": "...",
  "customer": { "number": "+1234567890" }
}
For inbound calls (via the assistant-request webhook):
Copy code
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "variableValues": {
      "callDirection": "inbound",
      "firstName": "Jane"
    }
  }
}
You can then reference this variable in your prompt to control the first message logic. Alternative: Use separate assistants for inbound and outbound calls, each with its own first message. Best regards, Oshi Raghav Customer Support Vapi
h
Can you answer to this thread? https://discord.com/channels/1211482211119796234/1483007168943755316 It's urgent, I have to finalize the agent with client
c
Thank you for providing the thread, I do see our team is looking into that. Please share your call id (in the original thread) where issue is mentioned, team will get back to you asap.