feat: working on call function

This commit is contained in:
Rushil Umaretiya 2023-03-04 19:37:04 -05:00
parent ca4c78f340
commit 98dbe10a8d

View File

@ -34,7 +34,7 @@ app.post("/call", (req, res) => {
// Use <Record> to record and transcribe the caller's message // Use <Record> to record and transcribe the caller's message
const gather = twiml.gather({ const gather = twiml.gather({
action: "https://eowj0ew8hq7190e.m.pipedream.net/respond", action: "/respond",
method: "POST", method: "POST",
input: "speech", input: "speech",
language: "en-US", language: "en-US",
@ -49,12 +49,26 @@ app.post("/call", (req, res) => {
res.send(twiml.toString()); res.send(twiml.toString());
}); });
app.post("/respond", (req, res) => { app.post("/respond", async (req, res) => {
let transcription = req.body.TranscriptionText; let transcription = req.body.SpeechResult;
console.log(transcription); console.log(transcription);
const twiml = new VoiceResponse(); const twiml = new VoiceResponse();
twiml.say(`You said, {$transcription}`); twiml.say(`You said, ${transcription}`);
twiml.say(`Don't kill yourself.`);
const gather = twiml.gather({
action: "/respond",
method: "POST",
input: "speech",
language: "en-US",
speechTimeout: "auto",
});
gather.say("Tell us what makes you sad.");
res.type("text/xml");
res.send(twiml.toString());
}); });
// Create an HTTP server and listen for requests on port 3000 // Create an HTTP server and listen for requests on port 3000