wise-white
wise-white15mo ago

Using caller ID to identify callers

I can't seem to make this work but I know that it should be possible. Is there a way to identify a caller and take certain actions by the caller's phone number? Here is what I did: I uploaded a file called contact-list.docx and it has a list of names and phone numbers. Then in the prompt, I said if the caller's number matches any of the numbers in this file, refer to the caller by their name rather than asking for it. It never seems to work but it should work based upon my understanding. Am I right?
46 Replies
Vapi
Vapi15mo ago
@Michael P Absolutely, you're on the right track! Identifying a caller by their phone number and taking specific actions based on that information is indeed possible. However, to make this work, the phone numbers and associated names need to be programmatically accessible to your Voice API. If you've uploaded a file like contact-list.docx, you'll need to ensure that the contents of the file are read and processed into a format that your Voice API can use during calls. Typically, this would involve parsing the document and storing the data in a database or in-memory data structure that the API can query against when a call comes in. Here's what you need to do: 1. Parse the contact-list.docx file to extract the names and phone numbers. 2. Store this information in a structured format, such as a database or a key-value store. 3. Modify your Voice API logic to query this data when a call is received to match the caller's number. 4. If a match is found, use the associated name in the conversation. If you need assistance with any of these steps or if you're unsure how to proceed, please ask support for more info on this. They can guide you through the process or provide you with the necessary tools to integrate the contact list with your Voice API setup. You can continue this conversation by mentioning me in the message.
wise-white
wise-whiteOP15mo ago
Perfect! I am going to try this right now and will let you know if it works. Thank you!
wise-white
wise-whiteOP15mo ago
Hi so I tried it and it doesn't seem to work. I did it quickly just as a test, this is what I did: 1) I created a function called look_up_contact which, given a phone number, will return a name (or it will return None if the name is not in the list) 2) In my prompts, I wrote this:
Before you do anything, at the very outset of the call, get the caller’s phone number from the caller ID and call the “look_up_contact" function. This will check to see if the caller is in Michael’s list of contacts. If it is, the function will give you their name, otherwise it will return “None”. If you have the caller’s name, please greet them warmly immediately by their first name, thank them for the phone call, and remember their name for the duration of the call.:
It didn't work. I called and she didn't know who I was. @Vapi is there anything obvious that I'm doing wrong here?
No description
Vapi
Vapi15mo ago
@Michael P It sounds like you've taken the correct steps in creating a function to look up contacts. However, if the assistant did not recognize you when you called, there could be a few areas to check: 1. Function Invocation: Ensure that the look_up_contact function is being correctly invoked at the start of the call. This means checking that the assistant is programmed to automatically execute this function with the caller ID as soon as the call is connected. 2. Caller ID Retrieval: Verify that the system is correctly retrieving the caller ID and passing it to the look_up_contact function without any formatting issues. 3. Function Execution: Test the look_up_contact function independently to confirm that it works as expected. Provide it with a known phone number from your contact list to see if it returns the correct name. 4. Prompt Logic: Review the logic in your prompts to ensure that it correctly handles the name returned by the look_up_contact function. If the function returns a name, the prompt should use it; if it returns None, the prompt should proceed without using a name. 5. Integration: Make sure that the function and the prompts are fully integrated into the call handling process of your Voice API setup. 6. Error Handling: Implement error handling to catch any exceptions or issues that might occur when the look_up_contact function is called, which could prevent it from working as expected. If you've checked all these areas and it still doesn't work, there might be a deeper integration issue or a missed step in the setup process. In that case, it would be best to consult the support documentation for your Voice API or reach out to the support team for further assistance. They can provide more detailed guidance based on the specifics of your system.
like-gold
like-gold15mo ago
Just a tip - that does not work this way. 1. You need to have that information in a database. 2. When they call your inbound number it will hit Vapi Server 3. When it hits the server and remembers the number a trnasient assistant can be created.
wise-white
wise-whiteOP15mo ago
Hi @Chowderr I wish I saw this message earlier. I'm not understanding. Why does it need to be in a database? Can't I hardcode it first as a test? It's a simple Python Flask app that takes a phone number and returns a name. The problem is, the agent never seems to call it. I even created a super simple agent with only this prompt: "Please call the lookup_contact function with the caller’s number and greet the caller by the name returned from the function. Then continue to have a casual conversation."
like-gold
like-gold15mo ago
This is an inbound call correct?
wise-white
wise-whiteOP15mo ago
yes
like-gold
like-gold15mo ago
Vapi
Inbound Support Example ⚙️ - Vapi
Let's build a technical support assistant that remembers where we left off.
wise-white
wise-whiteOP15mo ago
yep, I actually have an advanced agent with many custom functions, all working great... but I'm struggling with this one problem, how to detect the number of the caller without asking for it I know that VAPI has it because it's in the logs
like-gold
like-gold15mo ago
@Michael P 1. Saving a customer in Vapi is not possible. You can't add an UUID. (I know because the endpoint is not public, plus this is something I wanted to do as well. 2. If this is an inbound call, Vapi will remember by the number, which will ping a transient assistant that you create (not the Dashboard). It has nothing to do with a function. The page I attached kind of explains this, which is why it can't be hard coded. (maybe it can, but to my knowledge you can't) If i am wrong @Sahil please correct me.
wise-white
wise-whiteOP15mo ago
Thanks @Chowderr .. I don't want to save the customer though, I just want to know the customer's incoming phone number without having to ask for it.
like-gold
like-gold15mo ago
I am not talking about saving a number. Just trting to lead you in the right direction if this IS a inbound call once again.
wise-white
wise-whiteOP15mo ago
Check this out, it's the log file. That 239 number is mine, and the 512 number is the agent. So VAPI has the number of the incoming caller, I just don't know how the agent can obtain it during the call.
No description
like-gold
like-gold15mo ago
This would go to your server...
wise-white
wise-whiteOP15mo ago
does that make sense? maybe it's not possible
like-gold
like-gold15mo ago
You always get that..
wise-white
wise-whiteOP15mo ago
right - can I get it during the call? so, for example, the agent can see "oh, this is 239-351-6518, it is Michael P, hi Michael P" I wrote a function to look up the contact but the agent needs to send the number
like-gold
like-gold15mo ago
Even with that being said I do not think it will work how you want it to but we won't know until you try. You should look at the server events. They explain that.
wise-white
wise-whiteOP15mo ago
well the problem is that she never makes the function call... I have other ones, like for example I have one where she asks some questions, takes notes, then emails them. That works fine, she does it as instructed. But in this case, she never does the lookup even though I tell her to do it specifically in the prompt
like-gold
like-gold15mo ago
I assume you have assistant set not to speak, the person speaks then the functions runs?
wise-white
wise-whiteOP15mo ago
I have her say "Hello" first
like-gold
like-gold15mo ago
Seems kind of backwards compared to how Vapi has it set up.
wise-white
wise-whiteOP15mo ago
do you think that's the issue?
like-gold
like-gold15mo ago
Well lets make it make sense... Someone is calling in... You want the assistant to speak first? Why when you want the function to run? At what time? Also you kind of have not specified the function. If it is looking something up it needs to go to a database and do that.
wise-white
wise-whiteOP15mo ago
I guess the idea is that she answers, I start talking and she immediately addresses me by my name
like-gold
like-gold15mo ago
i keep trying to explain that Vapi does not do that. yes the number is in the call log, but that has nothing to do with Vapi "storing it". So think you should look at the page I sent. That is exactly what happens.
wise-white
wise-whiteOP15mo ago
For example, this works for me; I wrote this prompt "Your job is to take detailed notes from the caller, including their FULL name (first and last), a call back number, and notes about why they’re calling. Collect all this information before calling the receive_note function. Do not call receive_note until you have gathered all necessary details." - and she indeed calls that function and sends the note. but I can't get her to call my lookup_contact function 😦
like-gold
like-gold15mo ago
When the number hits the server you can have that happen .
wise-white
wise-whiteOP15mo ago
oh, and when does that happen?
like-gold
like-gold15mo ago
when they call...
wise-white
wise-whiteOP15mo ago
OK, well that's good, so I call the number, it's inbound, the agent answers, she has my number. Now how do I get her to actually use it and call my function?
like-gold
like-gold15mo ago
When a number calls your server, you will get a certain request. You can search your data base and create a transient assistant to do what you are suggest.
No description
like-gold
like-gold15mo ago
I do not use a function to do what you are suggesting. There is no need.
wise-white
wise-whiteOP15mo ago
well, there is in this case because I need to take that number and look up the information about the caller - based on their number I can tell the agent their full name and email address that's what the function does but I don't get why the agent has to ask the caller for their number when she should already know it
like-gold
like-gold15mo ago
Once again, the number always comes in with the call. All of this is dynamic, so just map the number in the function. I never said the agent is asking the caller for anything. I do not think you have looked at the page I have tagged.
wise-white
wise-whiteOP15mo ago
I did, remember I've written a lot of functions, that's one of the most basic pages
like-gold
like-gold15mo ago
@Michael P Hope this helps. Not a function here.
No description
wise-white
wise-whiteOP15mo ago
looking... you're right, I think this is helpful 😉 I was clearly missing a big part here
like-gold
like-gold15mo ago
@Michael P Later down the line what you are asking might be possible in Vapi. Right now it is not. This is the only way for Vapi to "remember" anything.
wise-white
wise-whiteOP15mo ago
I was thinking of writing to a file then uploading the file automatically through the API to the knowledge base as another way to remember things kind of hacky but figured it might work
like-gold
like-gold15mo ago
No, and that is not really remember, Plus none of those beat it just hitting the server and doing all of that by itslef. Its Transient, meaning its dynamic. You would already have all of the information.
wise-white
wise-whiteOP15mo ago
well, what if an agent took detailed notes about the call, then wrote them into a file at the end of the call then uploaded that new file to the knowledge base at the end then restarted... it'd have that knowledge persistent, no? I haven't tried it but in theory it sounds like it could work
like-gold
like-gold15mo ago
My friend please trust me when I say that is not a good way to do that in any platform. If you have a tabase why even need the KB. That does not make sense.
wise-white
wise-whiteOP15mo ago
🙂 I said it was hacky lol anyway that's a topic for another day.. I'll keep digging at this, thanks for pointing me in the right direction
exotic-emerald
exotic-emerald15mo ago
@Chowderr is right about it. You will need to use the serverURL flow. and get the number from the call parameter.

Did you find this page helpful?