Test a Phone Number's Interoperability, Caller Id, Reputation, and STIR/SHAKEN Attestation Level
Products > Super Network > Phone Numbers > Manage > Buy a number
Buy a Twilio Number
Verify the purchased Number
Find Twilio Functions and Assets in the Console
Create a new Service called incoming-number-detector
Create a new Function in the incoming-number-detector Service called /main
Paste the following javascript in the Editor for the /main Function.
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
let fromNumber = event["Caller"]; // The From number is contained in this key
let speechFriendlyFromNumber = fromNumber.slice(1).split("").join(" "); // Format it better for speech
// Add a few cosmetic pauses
twiml.pause({
length: 2
});
twiml.say({ voice: "alice" }, "Welcome to test number dot org.");
twiml.pause({
length: 1
});
// Tell the caller what we have detected as the From Number
twiml.say({ voice: "alice" }, "You are calling from " + speechFriendlyFromNumber + ".");
twiml.pause({
length: 1
});
// Bid them farewell
twiml.say({ voice: "alice" }, "Goodbye.");
return callback(null, twiml);
};
Enable the Function for incoming calls to the new Number
Verify the Function is the default for the new Number