Get Digits from Twilio Payload?
# support
a
I am able to pass "Digits": "XXXXX", from twilio when calling VAPI api https://api.vapi.ai/twilio/inbound_call. Is there a way when VAPI call my server url when getting assistant that I can access those digits? @Shubham Bajaj @Sahil
v
Hi there! 👋 Based on the documentation I've found, VAPI doesn't directly support retrieving the "Digits" parameter from Twilio's payload during a server callback. However, there's a workaround using TwiML to handle this: 1. You'll need to set up TwiML's
gather
function to capture digits from incoming calls:
Copy code
javascript
// /api/twilio/call endpoint
const twiml = new VoiceResponse();
twiml.gather({
  numDigits: 3, // Example to gather 3 digits
  method: "POST",
  action: `${process.env.NEXT_PUBLIC_VAPI_SERVER_URL}/api/twilio/gather`,
});

twiml.redirect({
  method: "POST",
}, "https://api.vapi.ai/twilio/inbound_call");
2. Then handle the gathered digits in your server code:
Copy code
javascript
// /api/twilio/gather endpoint
const formData = await req.formData();
const digits = formData.get("Digits");
console.log("Digits", digits);

const twiml = new VoiceResponse();
twiml.redirect({
  method: "POST"
}, "https://api.vapi.ai/twilio/inbound_call");
One important note: After gathering DTMF tones, Twilio changes the call status to "in-progress" which can cause a 400 error with VAPI (which expects "ringing" status). A suggested workaround is to use a conference call setup to transfer the call to the VAPI assistant after gathering digits. Let me know if you need more details on implementing this solution! 😊 Source: - [Discord Thread Discussion](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1342459464346767492)
v
We are not offering this feature right now. However, we are working on the DTMF feature request and assessing user needs. Based on that, we will develop the functionality. Could you share more details about how you plan to use the DTMF feature?
a
I got it working 🙂 Was a way to share one line for different assistants, it's pretty cool 🙂
call 1 number, put in something on the keypad like #23 for example and connect with an agent 🙂
v
How did you made it work?
a
Setup a twiml bucket that takes the code entered and send to a webhook that then takes that data and does cool stuff with it and then connects to vapi and since we have the Twilio SID we can use that as a key across the call to maintain session state and know which agent to load up 🙂
it was fun when i got it working! Now i could have 1 to many where 1 phone number can have many unique agents 🙂
v
Dayum, pretty unique solution. Mind making a video or showcasing the code. It will help lot of people.
a
yes no worries i can do it 🙂
its pretty creative 😛
v
Thankssss!
a
Cool what is their use case they are trying to solve so i can set up the video?
v
To get the proper phone number details or credit card details or it can be to route to different agent.
a
Rem this is on initial call, so when they first call the number it takes down the number, is this what you think would be helpful or were you thinking this works a different way?
Incoming call -> take digits -> VAPI -> load transient agent based on digits
v
Ah, I see. I was thinking during the call you are able to get the keypad input. But, still it will be helpful.
a
VAPI can set this up by doing... 1. You need to enable DTMF digits to be sent via the WebSocket by adding the track="both" attribute to the element. you dont have both currently. 2. for this https://api.vapi.ai/twilio/status capture the following { "event": "dtmf", "digits": "123", "callSid": "CA1234567890abcdef" }
this would allow for these numbers to be captured and then we could inject them into the conversation in some way to insure we have captured them correctly.
Copy code
curl -X POST 'https://aws-us-west-2-production1-phone-call-websocket.vapi.ai/7420f27a-30fd-4f49-a995-5549ae7cc00d/control' 
-H 'content-type: application/json' 
--data-raw '{
  "type": "add-message",
  "message": {
    "role": "system",
    "content": "New message added to conversation"
  },
  "triggerResponseEnabled": true
}'
this would allow people to enter a credit card nnumber etc and then vapi can capture it from Twilio and then add to the context of the current call 🙂
v
Thanks, Titus!
a
Btw I saw a while ago a way to have a server url so if a number is called it can use that url instead of getting an assistant for that phone was that removed or what I hallucinating lol would be handy for me since I may want diff urls associated with each number and not rely on the main server url
Hope that made sense lol
Number -> own url that is hit when number called so I can generate transient agent for example
v
Yup, thanks!
a
is this available or am i missing it?
v
Nope.
a
can you check out concurrency we hit some limit because our automation went down and when we updated it the queue started hitting vapi causing Over Concurrency Limit.
how can i check in realtime if we have come down for concurrency
v
Hey AiTitus, on your dashboard you have a section that shows your current concurrency and you can sort by day, hour, minute etc. Are you looking for a programatic way to check IE before a call is started?
a
@Mason thanks! is there an API for concurrency so I can check?
IE?
v
Unfortunately there isn't a native way to directly query concurrency. Your best bet would to be to keep track of it on your end if you needed to do something programatic with the live concurrency. Definitely think it's worth a feature request though my friend: