llamanodes / web3-proxy

Fast loadbalancing and caching proxy for Ethereum or chains with similar JSON-RPC methods
https://llamanodes.com
GNU General Public License v3.0
148 stars 33 forks source link

LlamaNodes Premium | Email logic for notifying users their balance is low #122

Closed LlamaMB closed 1 year ago

LlamaMB commented 1 year ago

LlamaNodes Premium | Email logic and full feature for notifying users their balance is low:

Context: When a user’s Premium Balance is low, we want to email them with a remainder to top up - This is an opt-in feature.

Tech: We will capture the emails upon sign-up and then use SendGrid’s API to trigger and manage all the email notifications.

Steps: 1) Input: When a users signifies they want to receive email notification and input their email.

2) Collect email and verify it via verification email (to reduce spam issues) via PR #119 and PR #117 -Email collection is ask & completed in the account creation phase. -Email verification template (placeholder) can be found here: https://mc.sendgrid.com/design-library/your-designs/37bf6a74-924a-40db-9b32-fa7f4e39584d/preview

3) Output: When users balance is low | Less than $50.00 (?) -We have a built out email template (w/ graphics already completed).

Please let me know if you need any other information, thanks!

yenicelik commented 1 year ago

Use this to implement the Sendgrid API https://www.twilio.com/blog/send-emails-rust-sendgrid

yenicelik commented 1 year ago

The payload should look as follows, with the template-id being the one I created via the GUI

curl -X "POST" "https://api.sendgrid.com/v3/mail/send" \
     -H 'Authorization: Bearer <<YOUR_API_KEY>>' \
     -H 'Content-Type: application/json' \
     -d '{
   "from":{
      "email":"example@.sendgrid.net"
   },
   "personalizations":[
      {
         "to":[
            {
               "email":"example@sendgrid.net"
            }
         ],
         "dynamic_template_data":{
            "total":"$ 239.85",
            "items":[
               {
                  "text":"New Line Sneakers",
                  "image":"https://marketing-image-production.s3.amazonaws.com/uploads/8dda1131320a6d978b515cc04ed479df259a458d5d45d58b6b381cae0bf9588113e80ef912f69e8c4cc1ef1a0297e8eefdb7b270064cc046b79a44e21b811802.png",
                  "price":"$ 79.95"
               },
               {
                  "text":"Old Line Sneakers",
                  "image":"https://marketing-image-production.s3.amazonaws.com/uploads/3629f54390ead663d4eb7c53702e492de63299d7c5f7239efdc693b09b9b28c82c924225dcd8dcb65732d5ca7b7b753c5f17e056405bbd4596e4e63a96ae5018.png",
                  "price":"$ 79.95"
               },
               {
                  "text":"Blue Line Sneakers",
                  "image":"https://marketing-image-production.s3.amazonaws.com/uploads/00731ed18eff0ad5da890d876c456c3124a4e44cb48196533e9b95fb2b959b7194c2dc7637b788341d1ff4f88d1dc88e23f7e3704726d313c57f350911dd2bd0.png",
                  "price":"$ 79.95"
               }
            ],
            "receipt":true,
            "name":"Sample Name",
            "address01":"1234 Fake St.",
            "address02":"Apt. 123",
            "city":"Place",
            "state":"CO",
            "zip":"80202"
          }
      }
   ],
   "template_id":"[template_id]"
}'
BlinkyStitt commented 1 year ago

Duplicate of #38