mirror of
https://github.com/vitalityAI/therapist.git
synced 2025-04-16 17:40:16 -04:00
feat: basic calling express server
This commit is contained in:
parent
4e6c94fbfa
commit
977c10c866
|
@ -1,3 +1,4 @@
|
||||||
OPENAI_API_KEY="openaikey"
|
OPENAI_API_KEY="openaikey"
|
||||||
TWILIO_ACCOUNT_SID=account_sid
|
TWILIO_ACCOUNT_SID=account_sid
|
||||||
TWILIO_AUTH_TOKEN=auth_token
|
TWILIO_AUTH_TOKEN=auth_token
|
||||||
|
TWILIO_PHONE_NUMBER=phone_number
|
29
call.js
29
call.js
|
@ -1,3 +1,30 @@
|
||||||
// call.js
|
|
||||||
import * as dotenv from "dotenv";
|
import * as dotenv from "dotenv";
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
import twilio from "twilio";
|
||||||
|
import express from "express";
|
||||||
|
|
||||||
|
const accountSid = process.env.TWILIO_ACCOUNT_SID;
|
||||||
|
const authToken = process.env.TWILIO_AUTH_TOKEN;
|
||||||
|
const phone_number = process.env.TWILIO_PHONE_NUMBER;
|
||||||
|
|
||||||
|
const client = new twilio.Twilio(accountSid, authToken);
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
app.post("/voice", (request, response) => {
|
||||||
|
console.log("got call!");
|
||||||
|
const voiceResponse = new twilio.twiml.VoiceResponse();
|
||||||
|
voiceResponse.say({ voice: "alice" }, "hello world!");
|
||||||
|
|
||||||
|
// Render the response as XML in reply to the webhook request
|
||||||
|
response.type("text/xml");
|
||||||
|
response.send(twiml.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create an HTTP server and listen for requests on port 3000
|
||||||
|
app.listen(3000, () => {
|
||||||
|
console.log(
|
||||||
|
"Now listening on port 3000. " +
|
||||||
|
"Be sure to restart when you make code changes!"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user