Skip to content

Commit

Permalink
created the basics skeleton of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebones committed Sep 9, 2023
0 parents commit 9809cec
Show file tree
Hide file tree
Showing 6 changed files with 1,846 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@


############### TWILIO API STARTS ##########################
TwILIO_ACCOUNT_SID = AC340f3a25143d73e51194ddd63d245fd0
TWILIO_AUTH_TOKEN = 81c8d68b5e70928bb65710c358f2f1f3
############## TWILIO API ENDS ######################


NEXT_PUBLIC_GRAPHQL_URI=http://localhost:5001/graphql
#NEXT_PUBLIC_GRAPHQL_URI=https://soil-api-backend-developai2.up.railway.app/graphql
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
18 changes: 18 additions & 0 deletions api/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import axios from "axios";
import dotenv from "dotenv";
dotenv.config();

const baseURL = process.env.NEXT_PUBLIC_GRAPHQL_URI;

console.log("baseURL = ", baseURL);
const apiClient = axios.create({
baseURL,
method: "POST",
});

apiClient.interceptors.request.use(function (config) {
config.headers["Access-Control-Allow-Origin"] = "*";
return config;
}, null);

export default apiClient;
48 changes: 48 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const dotenv = require('dotenv');
const twilio = require('twilio');
const cors = require("cors");
const express = require('express');
const MessagingResponse = require('twilio').twiml.MessagingResponse;

dotenv.config();

const accountSid = process.env.TwILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = new twilio(accountSid, authToken);



(async () => {

const app = express();
const port = 3000;



app.use(cors())
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

// const url = await ngrok.connect(4000);
// console.log("server url: ", url)

app.post('/incoming', (req, res) => {
const message = req.body;
console.log("msg ", message)

const twiml = new MessagingResponse();
twiml.message(`I am busy now: `); //response message.
res.writeHead(200, { 'Content-Type': 'text/xml' });
res.end(twiml.toString());
});

app.listen(port, () => {
console.log(`Server running on http://localhost:${port}`);
});
})();






Loading

0 comments on commit 9809cec

Please sign in to comment.