Skip to content

nvignola/kuracado

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kuracado logo

Kuracado

Helping patients to get their medicine. Project for Dev.to - Twilio hackathon.

About

Its goal is to facilitate the process of getting the receipt from the doctor and sequentially getting the medicine from the pharmacy.

Kuracado offers a dashboard through which the doctor can communicate and put in communication the patients, and the pharmacy. It offers also a shipping monitoring when the pharmacy sends the medicine to the patient.

How it works

This application is a demo that assumes the existence of an actual database containing all the data regarding the actors involved in the system.

Every time a user sends a message to the WhatsApp Sandbox, the webhook is called and the server collects the data. The application uses the AJAX polling technique to continuously fetch new messages from the server.

Once the receipt is ready and transformed from HTML code to an image, it is sent to both the patient and the pharmacy. After preparing the medicine, the pharmacy texts the patient with the package's tracking code.

Receipt sent to the patient and the pharmacy

Since only one WhatsApp Sandbox is available, and all the users are registered in the same sandbox; the message from the pharmacy to the patient is passing through the doctor that works as an interceptor. This way, the messages received by the pharmacy will not be registered but just forwarded to the patient.

Twilio

Features

  • Dashboard to visualize incoming messages in realtime
  • Form to build the receipt
  • Monitor on the pharmacy shipment
  • Node.js web server using Express.js
  • Web user interface using Vue along with Bootstrap Vue for the UI components
  • Linting and formatting using Prettier
  • Interactive configuration of environment variables upon running npm run setup using configure-env
  • Project specific environment variables using .env files and dotenv-safe by comparing .env.example and .env.

Set up

Requirements

Kuracado Settings

Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Twilio account Sid Your primary Twilio account identifier - find this in the Console.
Twilio auth Token Used to authenticate - just like the above, you'll find this here.
Twilio phone number A phone number for the WhatsApp sandbox E.164 format - you can get it here
Patient phone number This is an existing WhatsApp phone number that will play the role of the patient E.164 format
Pharmacy number This is an existing WhatsApp phone number that will play the role of the pharmacy E.164 format
Server Url Is the tunnel url (e.g. using Ngrok). It is used to fetch the receipt image in the Whatsapp message

Local development

⚠️ Important steps ⚠️

  1. Before proceeding, it is mandatory to expose the /receive-message endpoint provided by the server. This is the webhook that Twilio calls every time there is an incoming message directed to our sandbox. It is possible to achieve this using ngrok. After the ngrok setup launch the command to generate the URL that exposes the local environment to the world:
# cd in the directory where ngrok is installed

# The port 1337 is the default port used by the server
# If a different port is used this command has to be launched with the correct port
./ngrok http 1337

Now copy the URL and paste it in the Twilio console in the section Programmable SMS > WhatsApp > Sandbox inside the WHEN A MESSAGE COMES IN input.

Sandbox Configuration - Twilio console WhatsApp

This Url is also needed for setting the Server Url environment variable

  1. To be able to send messages to the sandbox, it is mandatory to be registered. Go to Programmable SMS > WhatsApp > Sandbox and follow the instructions given.

Sandbox Partecipants - Twilio Console WhatsApp

After the above requirements have been met:

  1. Clone this repository and cd into it
git clone [email protected]:nvignola/kuracado.git
cd kuracado
  1. Install dependencies
npm install
  1. Set your environment variables
npm run setup

See Kuracado Settings to locate the necessary environment variables.

  1. Run the application

At the moment only development mode is supported.

Start the server

npm run server:dev

Start the client

npm run client:dev

Navigate to http://localhost:1234 and start texting your sandbox. That's it! 🎉

License

MIT