From 3cf99f0fd41c9c3ba1c774435fd0a2aa2a696cf3 Mon Sep 17 00:00:00 2001
From: Rushil Umaretiya <rushilwiz@gmail.com>
Date: Sat, 4 Mar 2023 19:40:15 -0500
Subject: [PATCH] feat: fixed callback routes

---
 src/call.js | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/call.js b/src/call.js
index 874ace5..5999bd5 100644
--- a/src/call.js
+++ b/src/call.js
@@ -14,21 +14,7 @@ const VoiceResponse = twilio.twiml.VoiceResponse;
 const app = express();
 app.use(express.urlencoded({ extended: false }));
 
-app.post("/voice", (request, response) => {
-  const city = request.body.FromCity;
-  console.log(`They're from ${city}!`);
-
-  // Use the Twilio Node.js SDK to build an XML response
-  const twiml = new VoiceResponse();
-  twiml.say({ voice: "alice" }, `Never gonna give you up ${city}.`);
-  twiml.play({}, "https://demo.twilio.com/docs/classic.mp3");
-
-  // Render the response as XML in reply to the webhook request
-  response.type("text/xml");
-  response.send(twiml.toString());
-});
-
-app.post("/call", (req, res) => {
+app.post("/receive", (req, res) => {
   // Use the Twilio Node.js SDK to build an XML response
   const twiml = new VoiceResponse();
 
@@ -50,10 +36,11 @@ app.post("/call", (req, res) => {
 });
 
 app.post("/respond", async (req, res) => {
+  const twiml = new VoiceResponse();
+
   let transcription = req.body.SpeechResult;
   console.log(transcription);
 
-  const twiml = new VoiceResponse();
   twiml.say(`You said, ${transcription}`);
   twiml.say(`Don't kill yourself.`);