Picnic1209 / EmailAlertsOnWhatsapp

Code for email alert project using sandbox
7 stars 2 forks source link

EmailAlertsOnWhatsapp

About

This repository contains the code which fetches recent mails from a user's gmail account and send it to his/her Whatsapp account using Twilio environment

Prerequistics

App Passwords

You can read more about it here

Setup

  1. Create Twilio Account and connect your whatsapp number to it (It's free)
  2. Go through the guide they provide and connect your whatsapp number such that you can send a message to the number and receive a message(Initially it would be something along the lines of "You send ")
  3. Navigate to the function page through the navigation bar at the left

FunctionScreen

  1. Create a new function (with any name you like) and copy the code in there.
  2. Inside the functions page, go to settings->Dependencies and make sure you have all the dependencies added as shown in the figure

dependencies

  1. Now go to settings->Environment Variables and then set emailID as your GMail id and passKey as your App Password(If you don't know about app passwords please read the pre-requistic paragraph above)

environment variables

  1. Save and select Deploy all
  2. Select the 'Copy URL' present just below the code editor to copy the link of the function after deploying.
  3. Now go to Programmable Messages->Settings->Whatsapp Sandbox Settings and paste the copied URL in step 8 into the 'WHEN A MESSAGE COMES IN' field in Sandbox Configuration
  4. Save and you are good to go

Features/Working

The chatbot searches for keywords and replies accordingly. The followinf keyword are currently implemented.

  1. Help : This gets the list of all keyword

helpKeyword

  1. mail/email : This gets the recent 5 emails

mails keyword

  1. mail/email + unseen : This gets the latest 5 unseen emails

unseen+mail keyword

  1. Hello/Hey : This just greets you and asks if you want to get mails. If you type es then it fetches the mails.

hello keyword

Future Plans