Greet with name - Incoming call
# support
m
we make calls using API and we say their name that we fetch from our records. but in some cases they dont pick up and call us back. is there a way where we can map the phone number and greet them with their name for incoming call
v
Yes, you can greet incoming callers by name using phone number mapping. Set up a server endpoint to handle Vapi's
assistant-request
, look up the caller by phone number, and return their name as a variable. Example:
Copy code
javascript
app.post("/api/assistant-selector", async (req, res) => {
  if (req.body.message?.type === "assistant-request") {
    const phoneNumber = req.body.call.from.phoneNumber;
    const customer = await crmAPI.getCustomerByPhone(phoneNumber);
    res.json({
      assistantId: "asst_customersupport",
      assistantOverrides: {
        variableValues: { customerName: customer.name }
      }
    });
  }
});
In your assistant's greeting, use: "Hello {{customerName}}! How can I help you today?" For setup details, see the [Vapi personalization guide](https://docs.vapi.ai/assistants/personalization). Source: - [Personalization with user information](https://docs.vapi.ai/assistants/personalization)
v
Message marked as helpful by @Marmik! 🎉
t
Sorry -- why is the dynamic variable (customer.number) not helpful here? Is it proving unreliable?
2 Views