Closed Usequickdeal closed 2 years ago
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
ℹ️ Googlers: Go here for more info.
@googlebot I signed it!
/**
app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true }));
//For authenticating dialogflow_session_client.js, create a Service Account and // download its key file. Set the environmental variable // GOOGLE_APPLICATION_CREDENTIALS to the key file's location. //See https://dialogflow.com/docs/reference/v2-auth-setup and // https://cloud.google.com/dialogflow/docs/setup for details.
const projectId = 'use-quick-deal-mobile-chatbot'; const phoneNumber = "+14155238886"; const accountSid = 'AC2d47726f2b6dd1562131167125d3733c'; const authToken = '3a008ee977e60161cfb688013204cc5a';
const client = require('twilio')(AC2d47726f2b6dd1562131167125d3733c, 3a008ee977e60161cfb688013204cc5a); const MessagingResponse = require('twilio').twiml.MessagingResponse; const sessionClient = new dialogflowSessionClient(projectId);
const listener = app.listen(process.env.PORT, function() { console.log('Your Twilio integration server is listening on port '
app.post('/', async function(req, res) { const body = req.body; const text = body.Body; const id = body.From; const dialogflowResponse = (await sessionClient.detectIntent( text, id, body)).fulfillmentText; const twiml = new MessagingResponse(); const message = twiml.message(dialogflowResponse); res.send(twiml.toString()); });
process.on('SIGTERM', () => { listener.close(() => { console.log('Closing http server.'); process.exit(0); }); });