Giter Club home page Giter Club logo

assessment-chatbot-api's Introduction

Node.js CI

Made for the COVID19 Chat bot

Pre-requisites

  1. Twilio Account
  2. AWS or any cloud provider for DB
  3. OpenCage for Geocoding to translate between Postal/Zip Code to Lat/Lon Coordinates

How to add a new Function

  1. Create a .js file in /twillioFunctions
  2. Ensure the function exports using exports.handler
const nearestCenter = async (context, event, callback) => {
}

exports.handler = nearestCenter

  1. To test locally, add the as a route to express
  2. See the example below
  const postalCode = req.body.postalCode
  // Pushing into Twilio format
  const mem = JSON.stringify({
    twilio: {
      collected_data: {
        ask_questions: {
          answers: {
            PostalCode: {
              answer: postalCode
            }
          }
        }
      }
    }
  })

  const event = {
    Memory: mem
  }
  const callback = (err, respond) => {
    if (err) res.send(err)
    res.send(respond)
  }
  const { handler } = require('./twilioFunctions/nearestHospital')
  handler(null, event, callback)
})

I am using .post to send a postalCode as a JSON

Then run npm run start

  1. Add a new rollup.config.js object
{
    input: 'twilioFunctions/${Name}.js',
    output: {
      file: 'functions/${Name}.js',
      format: 'cjs'
    },
    plugins: [resolve()]
  },

Remember to add this in the existing array

  1. Now, just do npm run deploy, this will create a new function in /functions folder and upload it to twilio
  2. Twilio takes packages, from dependencies under package.json

Update CovidBot

  1. Make changes to APIBot.json -> this is the dev bot
  2. use npm run update:ta to push those changes to twilio https://github.com/twilio/autopilot-templates

twilio SID and Auth Token

if twilio asks you for id and password, go to https://www.twilio.com/console/project/settings Account SID and Auth Token are here

.env

make sure ur .env looks like this AIRTABLE=AIRTABLE_KEY

OCD_API_KEY=Opencage key

CRON_PASS=any random letter, this will unlock airtable with lat,lng

ACCOUNT_SID=twilio SID

AUTH_TOKEN=twilio Auth Token

MYSQL_USERNAME=

MYSQL_PASS=

MYSQL_DATABASE=

MYSQL_HOST=

MYSQL_PORT=

DB migrate

install this https://github.com/sequelize/cli#installation

use .env to set ur admin username and password for mysql

There are two ways to migrate and seed:

  1. npm scripts:

    • run npm run seed
  2. Manual (using sequelize-cli)

    1. run npx sequelize db:migrate

    2. run npx sequelize db:seed:all

To generate Models/Seeders follow this example: run npx sequelize-cli model:generate --name HospitalDetails --attributes HospitalName:string,StreetAddress:string,City:string,Province:string,PostalCode:string,PhoneNumber:string,PID:string,lat:float,lng:float

assessment-chatbot-api's People

Contributors

adityatr avatar adityatr-paytm avatar heatenmistry avatar rajan-hiku avatar sbganesh avatar windh8 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.