Need Guidance on Personalizing Inbound Call Greeti...
# support
m
Hello Vapi Support Team, I hope you're doing well. I'm currently building an inbound AI receptionist using a Vapi Hosted Number and would appreciate your guidance on a specific use case. My goal is to personalize the greeting at the very beginning of an inbound call. Before the assistant speaks its first message, I would like Vapi to trigger my n8n workflow, which is connected to my CRM. The desired flow is: 1. An inbound call is received. 2. Vapi sends the caller's phone number to my n8n workflow. 3. n8n checks my CRM for a matching contact. 4. If a contact is found, n8n returns the customer's first name. 5. The assistant uses that first name in the very first greeting. Example: "Hi John, thank you for calling MD Smart Services. How can I help you today?" Currently, I have configured a Server URL, and my n8n workflow is being triggered successfully. However, the webhook appears to be receiving events such as
assistant.started
, which means the assistant has already started before my CRM lookup completes. I also tested returning values using:
Copy code
json
{
  "assistantOverrides": {
    "variableValues": {
      "customer_name": "John"
    }
  }
}
but the returned variable is not available in the assistant's first message. Could you please advise: 1. Is there a supported way to perform a CRM lookup before the assistant's first message is generated? 2. For inbound calls on a Vapi Hosted Number, is there an Assistant Request event, pre-call hook, or another mechanism that allows dynamic variables to be injected before the greeting is spoken? 3. What is the recommended approach for personalizing the first greeting using CRM data retrieved from an external system such as n8n? Any documentation, examples, or recommended architecture would be greatly appreciated. Thank you for your time and support. Best regards, MD MAHIUDDIN
j
you might need a pre-call webhook to handle the crm lookup before the assistant starts. check if vapi supports that or if there's a workaround in the docs
m
I don't see any pre call webhook. Now whats the solution?
j
maybe you can try delaying the assistant start until the crm lookup is done? or see if there's a way to inject the name in real-time once the call connects
s
Hi MD, Great question. The mechanism you're looking for is the assistant-request event. Here's how to set it up:
1. Remove the static assistant assignment from your phone number 2. Make sure your Server URL is configured on the phone number 3. When an inbound call comes in, Vapi will send an
assistant-request
webhook to your Server URL before the assistant starts, including the caller's phone number in the payload 4. Your n8n workflow receives this, does the CRM lookup, and returns the assistant configuration with a personalized
firstMessage
or
variableValues
Your n8n response should look something like this:
Copy code
json
{
  "assistantId": "your-assistant-id",
  "assistantOverrides": {
    "firstMessage": "Hi John, thank you for calling MD Smart Services. How can I help you today?",
    "variableValues": {
      "customer_name": "John"
    }
  }
}
Or if you want to use variable substitution in your assistant's first message, set the firstMessage to
Hi {{customer_name}}, thank you for calling MD Smart Services...
and pass the name through
variableValues
.
The key difference from what you tried:
assistant-request
fires before the assistant starts, while
assistant.started
fires after. That's why the variable wasn't available in time.