{"id":510,"date":"2022-10-18T13:19:30","date_gmt":"2022-10-18T13:19:30","guid":{"rendered":"http:\/\/lhotsetechnologies.com\/blog\/?p=510"},"modified":"2022-11-07T06:12:13","modified_gmt":"2022-11-07T06:12:13","slug":"how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws","status":"publish","type":"post","link":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/","title":{"rendered":"How to trigger mail dynamically using Sendgrid and Amazon AWS?"},"content":{"rendered":"\n<p><strong>Use case:-<\/strong><\/p>\n\n\n\n<p>Here we are taking a general use case. Let&#8217;s say we have a site where authors can submit their books for publishing. In the database their books table structure is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>While submitting the book, the author has to fill in the details like book name, description, author name and mail.<br>BOOK_ID is the auto generated primary key and IS_PUBLISHED is the book status which tells us if a book is published or not. It will be either YES or NO.<\/p>\n\n\n\n<p>Here are some sample records with two books having IS_PUBLISHED status as YES and the last one is having status as NO.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/cRxOEbwRHUaNDXiJ4hGxVlVxvqh19zh8VGIGUcTKySCU2Iqp3Auium9XFLPIYYcShNnvp1kyNMlOxjyoeDiSp87Obg8HGuk8Hxo6e1zP7SXMWSY81W-nv4HiKfVMWC2j32y2Sx7SDDv90p8Vt93VViGogCA_JhzW4bhTDy45KsiyZ9Fl9hFBsk5-vB6BAhBS63urjHcMmw\" alt=\"\"\/><\/figure>\n\n\n\n<p>So if the IS_PUBLISHED status is YES we have to send mail to the author.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Solution Summary:-<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/qHZOaPqCjG5FsnlwvQlpXvB8dlkMQx673_8OLICP2mItbXqmSdqC3sLPYi0OzufdjeF4vT6Oj_rJbE2Fw88ZfY5p1vcXp8E4zKJdfYUeLtwUIzyOKZLolenOLeF5FqF7FthQnFj9OuQpdHh1mzmp50hh683OXh-021Z_jhtER3OVyGQ6-oWM0AQjfZJOZ1dywUqzDRWmbg\" alt=\"\"\/><\/figure>\n\n\n\n<p>To achieve this we will be using AWS, Sendgrid and Oracle.<br><\/p>\n\n\n\n<p>1. We will create an event bridge which is triggered every 15 minutes and will call a lambda function.<br>2. The lambda function will connect to oracle db and call the procedure which will give us the records in the books table.<br>3. After getting the records we will then filter the records on the basis of IS_PUBLISHED status and add the records with YES status to sqs queue.<br>4. The SQS queue will again call the other lambda function. This lambda function will take the value one at a time, add the dynamic data to email templates like author_name and bood_name.<br>5. Then it will call the sendgrid api to deliver the email to the user.<br><\/p>\n\n\n\n<p><strong>Step 1 : Creating lambda functions<\/strong><\/p>\n\n\n\n<p>1. Goto AWS and login, then search <strong>Lambda<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/68qIq_f3K85xQ2IWqsx1ubf9oC09qQz9CHnV87gNaKac1qwn0O91bCD4uz0FDTFh1xsOl60lL5cx8SBlptrLldMVzr4aW1AOcc0__Zwlv0uCsiZjc1MqEZCZ1ykS7MZmtBhT3PQRM-N4jZRoxodrYxeH_LAy0IIAdqpbv65jZYWTMo3t-vlOj_X7Iw78ckR_yTknx9h-pQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now click <strong>Lambda <\/strong>and it will redirect to the Lambda page.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/SDHauHD59OhFIrsviKJSH9kFaDF_LCGtFnETcA7YeUbWfCix8mVAbOuwpYDmP545XaOhcGx0PCQD2FV6Hv57TxSC9z8BjHmeDbD8IomwaHalr4aHG-cl7-EmPUvTpZEGUnNNIPwHN0lW7Z5cn7d2mhsbo8skuNltNpWbEHb3IO7LOhq4F3PROXV7JKbkM0m5JOGDD6-p6Q\" alt=\"\"\/><\/figure>\n\n\n\n<p>2. Click on <strong>Functions <\/strong>on the left side.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/n0k8GMxmOe5m8wTLBny6l3VHTmnH4dSI0IBfUxNZbmzEwu8M5VOVGVEOM4VAyFmeJbTxf4bdiSvmDCT_zkjkrhRFZ1wjp4e93eFZXpGydhVGR6-wvSZVj4BEgXnCJjx6AoP2gBfvUbdtOWm8jEOugNrZ3csM85ks-lAeQAKkzje42M7P0yNVgsJH8Gxl5KNlAQWu1OyB8w\" alt=\"\"\/><\/figure>\n\n\n\n<p>3. Click on <strong>Create functions.<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/xlPsOFY3iOAeVn4-wTdElIVtXt1O6be6_00A73tccbvcYARoq5JZdRtwj7PNUV7yeIgM3nPB5oAeEe_JvQHMSQWlfdP48BFbQZ-kf7mdy_cYP1zoMIXwdjLjzi7Lj4nvHIgK05q5krDOuxv7BPCyYbitrxMZnuWPFObMNyiNsVt4euASfc-xAR_hfKlmUTbCk_2x2xYSrA\" alt=\"\"\/><\/figure>\n\n\n\n<p>4. Select the type of lambda from the given options<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/UAyu_hueJDA9pjWRzGpJL0mMKGSt_VCxW4Yndaw6Bm_mzl1esdYTb5dMEWdTAVxkNuGiM5DOqQ4BovOdQF4_brk9XnkUdHpnlEeSdnKJ1sufA3Ke9s5sGXjlRk9-whLmJffi9-tszSBmeuwG9xqU2YfKOD0bRTXPab-Bdqbn02K339rcsWnvxCYgZ9tHrd1TWj3iVXYVXg\" alt=\"\"\/><\/figure>\n\n\n\n<p>5. Enter the lambda name, runtime environment(programming language we want to use) and architecture.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/i6VNI9S6tzWkkXH-04XZ5E-cEhHbSk9QMwtb2B6ohXwHvcHjRTqCtaNz5LKq_Jdctx6JmHexpnTMcIMtgbHniHweeITteDZDuQhOjmW9cm3yklFMX76IjdyLGlh8rqkO_OPAvCpyO7JODqpIzs9E3ELKFZsazbAYsCqSzJrDBA9Vs3r-vrg5kXEzoKp0X1yqHZKYF2xt4Q\" alt=\"\"\/><\/figure>\n\n\n\n<p>6. Then click the create function button.<br><\/p>\n\n\n\n<p>7. Now create another lambda function same as above.<br><em>(For more info on AWS lambda functions visit :- <\/em><a href=\"https:\/\/docs.aws.amazon.com\/lambda\/latest\/dg\/getting-started.html\"><em>https:\/\/docs.aws.amazon.com\/lambda\/latest\/dg\/getting-started.html<\/em><\/a><em>)<\/em><\/p>\n\n\n\n<p><strong>Step 2 : Create event bridge which fires every 15 minutes<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/4WpAkJznT4HgEJIJNyVC5CRm055-d3IzM_t1VjKB3ay-SxnEPKm3xkcjfVXY7u2W0tokLClDqvxGLRJNGbC0VgUKPdm24eUwIURpX53MwnmYGc6LtwZvxavN_5P3WS3fDLy3rMWrF5d6ktThlKhHtvXlPla9gAQ1-A9IkxF7Wr12a9v4M2YqVVP9mlq1S4FnpuMMUHeX0g\" alt=\"\"\/><\/figure>\n\n\n\n<p>1. Search Eventbridge.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/kY7x4D-UxjPfZazGqKz2D5G5mjJ_5AVOaqQsXtDFZW2N7WwSRxORjui0yGsO-Op_7TYSe_sClEIapc5P5gyMsox64fgFZR67pSTTjMvJtNK21NfsyCJGa9-I6BTSOswSrNPMPgY32UvDUiipiR3Ong-OUA2crF0EXCXQnJZkxuLaaPlc2-PHDSCWNQ0TowAg8pXEh1SvDw\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/XsPqb6dRWjWlxKRUdFDiYrGZm0N-hJaz4g0FXglaq0z9HA4pkIbQojVsY73a_onWWNkSgxqxf7agvBC__4XVDp0huoxfz9h20KRjLwURGbOajf-tkEt3sB3r5EIGvIgtIdcUYe-fTI8jjRuWT9iuC6J14xLUMSMf1jzCQzcHQEZZETAZA06xhA3_YXGLWE12CBMjaRiCmA\" alt=\"\"\/><\/figure>\n\n\n\n<p>2. Click on <strong>Amazon EventBridge, <\/strong>then click on <strong>Rules.<\/strong><strong><br><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/e9_fJujGl5YdAPUZWXSkUeR7sWQQxog6ty_qArL3dUrNFPWb8IfLmh4sKvFDwWBlZK-GeGR4uOHLZxAylhzDLpxZrG_HSu6lAEIxj9z94k76ca4WZJ1LLY1iEfYs8kPXxbklb2lZvQWvtQoHhZ992bY-5E2Xne8DTS7imdCMjV-rcl9BdHew2FgAZX5sWANbfUSWDqVP7Q\" alt=\"\"\/><\/figure>\n\n\n\n<p>3. Click on <strong>Create Rule<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/624MOYMpDiSqvuGCVAWkENkLN7aXCefqWOfxQxTuGaIt6W2Y_BW9QwgR3FCA2ERVJwujol96aoEwIlW4bGQ_9PJODreqbHimlQ94gqbWEJA0vRA6UGFPr5gc10KHgDiDwJf7wNhCWInPjJ8ya2Q3Mbl7ZKGlwcpHSwDhpuIfZMydv2WGWuFWaf3DeDJUEXDUj32R10kJRg\" alt=\"\"\/><\/figure>\n\n\n\n<p>4. Now we have 5 steps which we have to follow<br><\/p>\n\n\n\n<p><strong>(i) Define rule detail<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/kpWh-XA6mzDb5ok8m-2I-DACxq5PV4QNzx8xSaCMc9bua1u_49wlHw8xSO2jEOw5CrrtOqLKsILa3WpntlqW8n1LWIUpKRtAbEoL30XhYOStWX3lacSxCLAP62k9Qs_jLz-MjWkFTIPrfwKP-U6QxjhFmA5fCC59lE6xcIPUWSkDCGv0Uy2X2fIBYapxYOasPk3t6Z93xg\" alt=\"\"\/><\/figure>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Add the lambda name, description and type of rule.<strong><br><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/ZO1WoiVH_6pAOV7i8tSQ--qPw1EQe-kev0TSQFaj_DGGH0xN4VNQurGoggyL1rWg-kYEecFwwnq_mTaf-cZUm6lpvA1nxYI6H0VVbHcjqBciX4fd4nR_l6Sy9Ov52orL9uoKHFRzEFOg0Kx4-GAUqWsEOE8mxywJQQ3DSqu8XPqzilF7kRtjfMdqCCZz-FmSGFySkDmRow\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>(ii)<\/strong>. <strong>Define Schedule<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/H_NiaE-SR-OwUedAqsLs_BXtkBN1-dwvKIckCwXTyLSHAcbBOyArTEdbgF6Z-A-5HvVj-R53UOnHsJeCducnetJdqpQS3vgOJx-ZSVu_vc8XYgNGSXF8KUxWy-ziWQul8NdQyCPxgwTwcDZ2nBMCzyWBWI7DesiQL_2mhCtC0dm5hW49v9DF6PeYkVrHYRnkLerjdymtgw\" alt=\"\"\/><\/figure>\n\n\n\n<p>Select the schedule pattern and the scheduled time accordingly.<strong><br><\/strong><\/p>\n\n\n\n<p><strong>(iii)<\/strong> <strong>Select targets<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/2sJdH6W2ABnT1iRHiysqO9C5rfOxjY95OkJK5pYvT50b4qlwhEjjnDgqhczfbyBP8K8VIpjzNGGfOSddnYEEdHZ1N1y7HV_RJ4ciRP5Z7SQ2VAfjuvldlgBJEMfQSOK9GDbraHdUs5uUmm94wyqS3qbW3r57NzFnHaX6UHtBNOt9r08HhTMCSs4zqfp2PGUDkwmSeoio8A\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/O2tW0Qz_5mbDx-1U7wqPyT9G5p6kL-aXNHS95y_VkXdziZtjtQF40yXrYSyfx1pBDiYaSEXlZGoPlS-LzikKlOzMJWrQfj10lwu4JTf5x-39KTvOHOFYw5hE1p1Znw0OSmvkUQFEX6yzd2Chj5PL-SPePN45uPefX7ZLHxE_OIHVAEjnlaN-RWM3R6hWnOlm0e-aqkArRQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>In target types we need to select <strong>AWS service<\/strong>, and in select a target we will select <strong>Lambda function<\/strong><strong><br><\/strong>After that we need to select the lambda function name in the <strong>Function dropdown.<\/strong><strong><br><\/strong><\/p>\n\n\n\n<p><strong>(iV) Configure tags<\/strong><\/p>\n\n\n\n<p>We can add tags here or we can skip it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/oSUTpHC-h89Jf3aiqAmcSnu3c0KCNudun7oPqn2NY5i83Qab8T1dSyQ_PWpqWWOY5ETil93y1B3GnK8nDpHd213KRzdYWz_hYqwmZr4crrwAvdetFTYa5CAlPpZWfXBv3EWpICd8Y6jSsgJNoqI56qFudWeMbSM8ns0tc8PoWSEWi5Cu4kdLvWW6e-qFvsuzsNONNjun_w\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>(v) Review and create<\/strong><strong><br><\/strong>In this step we can review all the configurations we have till now for the eventbridge creation. Then click create.<\/p>\n\n\n\n<p><em>(For more info on eventbridge visit :-<\/em><em><br><\/em><a href=\"https:\/\/docs.aws.amazon.com\/eventbridge\/latest\/userguide\/eb-create-event-bus.html\"><em>https:\/\/docs.aws.amazon.com\/eventbridge\/latest\/userguide\/eb-create-event-bus.html<\/em><\/a><em>)<\/em><\/p>\n\n\n\n<p><strong>Step 3 : Create Amazon SQS<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/QpV6qNMbmB33klJGQDQJEYuq8LgcnpueWbJvOwNp4CAKQrhhCk18NPWJ720o_ByZyblkkD-mR-vdDFG1sFboCCcxqRi_60r_yJqj7Y3em51Odl-RgV0K5ZHRSvBp0KC0ECLuVPbhiD7p56IASlY9xXE0EaL9lT5Jugv2gwItGoIJ8QtY2xJ-PL86zPTn_J1oym3SIJ8T4g\" alt=\"\"\/><\/figure>\n\n\n\n<p>1. Search SQS and click on <strong>Create queue<\/strong>.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/EeByIfAg1e9fpCwDmbRcAXbecPqfMHd76FohLMd3HHcMgGNYpLg5lJH7vjU_lTJzbtjYTnNkUmLNU4bUH2P13FrHEdlumEKozLcr5PSng4sSDoKlFpLFyJcCnSL_wMEnwYLf60lEKm1C5AuJnx3jo34Xgsk1IUGHEDvaf8St67ONZOMu3WWZLNzALDqtchB9aFFT599Qrw\" alt=\"\"\/><\/figure>\n\n\n\n<p>2. Select the type of queue, here we are selecting the fifo type.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/pfxmI0qZk_UESgUhrr-CIB8eZ23l9u1yLt7DlAhC9gap4yUpIkIxxZFBTwG-qHKQkNjSgsFQ6XzT0IwRbQQaketQk-QFqf4vEVv1W2MtVKSdJCKp8bZMeFelPELvfaWfvhwAmw6WMVzE-ZB9cStVkgjYHdsQPP191PXVoKpj-5o3EvR91wq9VoazhNIy6ZgDT_3DKmp4Sw\" alt=\"\"\/><\/figure>\n\n\n\n<p>3. Now enter the configuration like name, visibility timeout, message retention period, delivery delay, maximum message size, receive wait time, etc. <br>Then click <strong>create queue.<\/strong><br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/3RzDtnvnZY5iWQyte9t3wkdnTD_-L477QxcmoGu5t1SGJ5dvIFr5q8NwF32Tjfz-3KDidSk8ri-NC4SXTtGP4sk_qrwaRLpjr4N55rGwlpbWqN9EPGx8hhxp9SuEwU739R6h1eenbkUgN_PBpkDABTyQHpUPEp9mv6x1dLf6GMnD9v39Huu_FE_DawpK3sULRWLsCrsZfA\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/z-0ff6QZVuVTs2Rg4GvEJnxvvHS_gkFz-Oml4Py8Hihy6u4cR_aNexXaiMSm0I9YK4KM08eu92C_seFMcnIc17bJlGPX_T0TNkG0PegFugaBrOGms-CLGyFX8_jPTmQKyPP5LcGQinVO06JWAKpcWLdKqErUozPex7OD5vj-LCAfWZmiHQ_byLC56T9i0XJC_ESefVIWWw\" alt=\"\"\/><\/figure>\n\n\n\n<p>4. The queue is create<br>(<em>For more info on SQS visit-:<\/em><em><br><\/em><a href=\"https:\/\/docs.aws.amazon.com\/AWSSimpleQueueService\/latest\/SQSDeveloperGuide\/step-create-queue.html\"><em>https:\/\/docs.aws.amazon.com\/AWSSimpleQueueService\/latest\/SQSDeveloperGuide\/step-create-queue.html<\/em><\/a><em>)<\/em><br><\/p>\n\n\n\n<p><strong>Step 4. Sendgrid Configurations and Email Template<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/xVk__uRXPexHT7kxSWjCho1fEoCJjMhnntSzvFDPqMkKrSwJvomCwa--4GD4dKtS-xu8PeAxXwo7nDiiPRuNCFYK4whn5o6Nyw_mpggwP02a1vA7Fr2wJ5-ACqn2VGgghC_vng4Qmp-jPu3jZLVNVevoiqDb4IACtrJHUiXb8EgNgxmAd6pfikWDmDmiJuGOnPwDX5jyDg\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/tVygr_3j4gT70Fav3qutrNCxWtVOa-WOiF8bBK24Caw2kV7_0xce51jmmZK7j3dxpVftz3oLcM0hgw6_CZFuWub3zmJTtB4U45op-tHtSfAFa5SWJcpDekmZTPqP0bVRq619zvUy4SimWbCzfsxkpzF20eNuMwfYGKgVnW26YmoBcJEl8sAjKBuqM54hotvZqXHoJ-2npg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>1. <\/strong>Goto Sendgrid( <a href=\"https:\/\/app.sendgrid.com\">https:\/\/app.sendgrid.com<\/a> ).<br><strong>2.<\/strong> Click on settings in the left side panel, then click API keys. Now here we need to create API keys if it does not exist or does not meet the requirement. <br>To create the API key follow this documentation ( <a href=\"https:\/\/docs.sendgrid.com\/ui\/account-and-settings\/api-keys\">https:\/\/docs.sendgrid.com\/ui\/account-and-settings\/api-keys<\/a>)<br><strong>3. <\/strong>Once the api key is generated, now we need to create an email on which we can perform dynamic personalization.<br><strong>4. <\/strong>To create an email template, goto sendgrid homepage and click <strong>Email API <\/strong>from the left side panel and then select <strong>Dynamic Template.<\/strong><br><br><strong>5.&nbsp; <\/strong>Now click on Create Dynamic Template.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/LPNjIha-3g9UITKDbRpj2RUDIEgYC9Ft7SOj8hI3GpZOVvxNuGC9jsWAens6ZEZfVwib_P32t3yPuhBEJ_k34CktSLCssfQuxJr8BqZJ8zmD2wB1etZ8AUYvJ0vjNb1oBGycRNiaGQrxQTBG7f-PkzFnmj80XglXTRfsFbIvbkw3Tnm7vMhrOHWk5fN0GFp4GpqSmSvSuQ\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/hnz6Hkof2snd9wRil0BoXQYTlZ9YwsB3kPBdx9e2h3wJjZH22mItzfCG1R5rSmytR_8-ZwOQaQhANNH6AHYvP0v91IEQDBAKR5rtN92hgNoYntrkaYxYSArFyENxPu53px8VizsmKYtFd_jhKXodtIjoV_7SDFRQOXp6e-RNhcP1bt6C4csJiRVxPB0v2gt0dNiHKwIwqw\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/mJvkNoAI13eEivbhrNxIqYnRWhX89aZcWszr5yisRAiI4t0BqnDIVmSau6ihsXGfg_BZ_OX5O1xcRx4ihV-3SeIEbLIb8DI5DpSowFUldtgmqC4PHNvkNsrcpkUlTcVyVuKATWU5dxXpmQP_TMEp7MGgVzZMj3waQlppEAEEcq0QGKpBNQtP4tv9fP_mRy5pgk-bxpEosA\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>6. <\/strong>Then provide the template name<br><br><strong>7. <\/strong>Then click on <strong>Add Version<\/strong><strong><br><\/strong><strong><\/strong><strong><br><\/strong><strong>8. <\/strong>Now select the template, here we have selected the Blank template.<br><strong>9. <\/strong>Then select the <strong>Code Editor<\/strong> in <strong>Editing Experience<\/strong><strong><br><\/strong><strong><\/strong><strong><br><\/strong><strong>10. <\/strong>Once the template is created we will be changing the code in the HTML editor to our requirement.<br>Here we have used the following mail template code.<\/p>\n\n\n\n<p>&nbsp;&nbsp;&lt;html&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;head&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;Email Template&lt;\/title&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/head&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;body&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;Dear {{{author_name}}},&lt;\/p&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;Your book {{{book_name}}} has been published.&lt;\/p&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/body&gt;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&lt;\/html&gt;<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/CNHOXDz8F0FmFTMP6EVpq6vRO5xhGS1Rqvtw7defrmRXokIyJd6JfUf8oRRlJWFolHGF132Ai0NUZX86EZc2kgXiPDKsUCYkcljJy6Hmtv0Ahjy2DfBzK0wdMVtPDHYHluWR6wWUe50I9k2bsezwKaBQaQiNMTBd41exvJDZFtO5pfMXNAW9F64vRL9h7iaDR9CkVgZ-4w\" alt=\"\"\/><\/figure>\n\n\n\n<p>In the above code I have highlighted {{{author_name}}} and {{{book_name}}}, this is used when we need to pass dynamic data.<br>In sendgrid click on <strong>Test Data.<\/strong><br><\/p>\n\n\n\n<p><br>Here we have provided the below json,<br>{<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Subject&#8221; : &#8220;Sample Mail trigger, Book Published!&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&#8220;author_name&#8221; : &#8220;Tanner Christos&#8221;,<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&#8220;book_name&#8221; : &#8220;Quisque interdum&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/_MHJ37V-GbYs5ecQHLehT7pCEeGw8O0M2T1W7c3kp_CZbymHnmihxrdHpe9k5_bqLauwZSC6fwossrpHgkART1qBoiRAuwFPwV9r51VWSBNGi1FGqafIzQqw9vvEpR9Td4FW9s83vzKBkn58RkWHku6w_mwoKAO7CJ5oLrsMhgfxbWjbMNlKPUxXxhJUqrRkrIhJGvEXzg\" alt=\"\"\/><\/figure>\n\n\n\n<p>}<br>After saving it will render as follows,<br><\/p>\n\n\n\n<p><strong>11. <\/strong>In the above image, we can see that instead of <strong>{{{author_name}}} <\/strong>and <strong>{{{book_name}}} <\/strong>we are able to see the values which we have provided in json.<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/EtSyOtbHfkY516e-qekmEPf98GJ5dwFUhL3D0N05uprlQVEzUIDkMJmR_xNFc1Br1pjU4OKiAENOoNUF7zs3kKn_1-FQk41oeKWiBTFCkLNNPQFIh4iEQwfTxWw-zRySpY23KXt2Ae2cGsx7S9vl487rXDaqvWRmc_nwgAvByJgIjkQxvXOPtozUNCTbeuvRPwsCeLKK7w\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/WFqp6_3O2Z86yhEu4PK-1xdqHE9JVcK93nQJLoRx_XJlk8XveR4UjUlxy8By90akwoiPb-XWoFZHYpoCdHCBdwrkANXEkBjstmPCrXoJ5jA0yITEaik-VUOFh78l-1Vty4KJNyDaNIVBiXac_Dm4YRF0jtrKzjST7sAYbqLOz6B5QGo_jH5qKECXu0bGPKY49PZZwuaITA\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now we can also see that Subject is also coming and is the same as what we have provided in json.<br>To give a dynamic subject, click on settings on the left side.<br><br>Then give the subject value as {{{Subject}}}<br><br><\/p>\n\n\n\n<p>We can also test the mail template which we have created<br>1. Click on <strong>Settings<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/rG0awHY_xY1uviMrqFl3Ixn3Iuek8C1RoC-NQ6iC4tm3eVWEAIk90jfIocUtllzY_5obJZKgIjb6l4n7EezMQhfPK94fCnaI3sacFl2jgxo4n8tm7dLfvYcucjekRmjSriLOSfZ0Rd8_CYTgmxJsLQDAJuXPwA5wRuNKIlsR4vlxRWs0flrlwHyN3sWDm1BRYb7a0bhGvQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>2. Click on <strong>Test your mail<\/strong><strong><br><\/strong><strong><\/strong><strong><br><\/strong>3. Give the proper mails in <strong>From Address<\/strong> and <strong>To Address, <\/strong>then click on <strong>Send Test Message.<\/strong><strong><br><\/strong>You should be able to see the success message on top of the screen and also got the mail in your inbox.<br><\/p>\n\n\n\n<p>Sendgrid configurations and email template work is done here.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Step 5. Code Implementation for Lambda functions<\/strong><\/p>\n\n\n\n<p><strong>1. <\/strong>First Lambda function (GetRecordsFromDatabase)<\/p>\n\n\n\n<p>\tIn this Lambda function,&nbsp;<\/p>\n\n\n\n<p>\t<strong>i.<\/strong> we make a connection with the oracle database, execute the procedure and get the results.<\/p>\n\n\n\n<p><strong>\t<\/strong><strong>ii. <\/strong>While iterating over the result we need to check if the IS_PUBLISHED status is \t\tYES. Only if it is YES then we move forward otherwise skip that record.<\/p>\n\n\n\n<p><strong>\t<\/strong><strong>iii. <\/strong>Get the values like bookId, book name, author name and author email from \tthe result.<br><strong>\t<\/strong><strong>iv. <\/strong>Add the above data to sqs queue using SqsClient class.<\/p>\n\n\n\n<p><strong>\t<\/strong><strong>v. <\/strong>If the above step is done we will update the IS_PUBLISHED status to SUCCESS \tin oracle db else we will update it as FAILURE.<\/p>\n\n\n\n<p>In the below implementation, we are calling two db procedures.<\/p>\n\n\n\n<p><strong>i.<\/strong> fetch_book_records() :- This procedure fetches all the records present in the books table.<\/p>\n\n\n\n<p><strong>ii.<\/strong> update_book_status(?,?,?) :-&nbsp; This procedure updates the IS_PUBLISHED status for a particular book id in the books table.<br><br><\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.Context;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.LambdaLogger;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.RequestHandler;<\/p>\n\n\n\n<p>import oracle.jdbc.internal.OracleTypes;<\/p>\n\n\n\n<p>import org.json.JSONObject;<\/p>\n\n\n\n<p>import software.amazon.awssdk.regions.Region;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.SqsClient;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.model.SendMessageRequest;<br><\/p>\n\n\n\n<p>import java.sql.*;<\/p>\n\n\n\n<p>import java.util.HashMap;<\/p>\n\n\n\n<p>import java.util.Map;<\/p>\n\n\n\n<p>import java.util.Properties;<br><\/p>\n\n\n\n<p>public class GetRecordsFromDatabase implements RequestHandler&lt;Object, String&gt; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static final String STRING = &#8220;String&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static final String TASK_CREATED = &#8220;TASK CREATED&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static final String NOTIFICATION = &#8220;Notification&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public static final String SUCCESS = &#8220;Success&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;Connection conn = null;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;@Override<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public String handleRequest(Object input, Context context) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Properties props = new Properties();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String jdbc_url = &#8220;jdbc:oracle:thin:@localhost:1521:orcl&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String jdbc_user = &#8220;username&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String jdbc_pwd = &#8220;password&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;props.setProperty(&#8220;user&#8221;, jdbc_user);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;props.setProperty(&#8220;password&#8221;, jdbc_pwd);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class.forName(&#8220;oracle.jdbc.driver.OracleDriver&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn = DriverManager.getConnection(url, props);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CallableStatement statement = conn.prepareCall(&#8220;{call fetch_book_records()}&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.execute();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResultSet resultSet = (ResultSet) statement.getObject(1);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (resultSet.next()) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!resultSet.getString(&#8220;is_published&#8221;).equals(&#8220;YES&#8221;)) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String bookId = resultSet.getString(&#8220;book_id&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String bookName = resultSet.getString(&#8220;book_name&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String authorName = resultSet.getString(&#8220;author_name&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String authorEmail = resultSet.getString(&#8220;author_email&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqsClient sqsClient = SqsClient.builder().region(Region.EU_WEST_1).build();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;final Map&lt;String, MessageAttributeValue&gt; messageAttributes = new HashMap&lt;&gt;();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;messageAttributes.put(NOTIFICATION, MessageAttributeValue.builder().dataType(STRING).stringValue(eventName).build());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JSONObject msgJson = new JSONObject();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgJson.put(&#8220;bookId&#8221;, bookId);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgJson.put(&#8220;bookName&#8221;, bookName);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgJson.put(&#8220;authorName&#8221;, authorName);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msgJson.put(&#8220;authorEmail&#8221;, authorEmail);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Message Json : &#8221; + msgJson);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sqsClient.sendMessage(SendMessageRequest.builder()<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.queueUrl(&#8220;<a href=\"https:\/\/sqs.us-east-2.amazonaws.com\/123456789012\/sampleQueue\">https:\/\/sqs.us-east-2.amazonaws.com\/123456789012\/sampleQueue<\/a>&#8220;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.messageBody(msgJson.toString())<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.messageAttributes(messageAttributes)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.delaySeconds(10)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.build());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;updateUserStatus(bookId, &#8220;Success&#8221;, authorEmail);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;updateUserStatus(bookId, &#8220;Failure&#8221;, authorEmail);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.close();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Stored procedure called successfully!&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} finally {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.close();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (SQLException e) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return SUCCESS;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<br><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;private void updateUserStatus(String bookId, String bookStatus, String emailId) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CallableStatement statement = conn.prepareCall(&#8220;{call update_book_status(?,?,?)}&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.setInt(1, Integer.parseInt(bookId));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.setString(2, bookStatus);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.registerOutParameter(3, java.sql.Types.VARCHAR);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.execute();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String status = statement.getString(3);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;User status updated: &#8221; + status);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Error : Exception &#8221; + e.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} finally {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement.close();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (SQLException e1) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e1.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>2. <\/strong>Second Lambda function (SendMailToUser)<\/p>\n\n\n\n<p>In this Lambda function,&nbsp;<\/p>\n\n\n\n<p><strong>\t<\/strong><strong>i. <\/strong>We take one object from sqs queue. Get the book details.<\/p>\n\n\n\n<p><strong>\t<\/strong><strong>ii. <\/strong>Create the dynamic personilization. Add the sender and receiver information.<\/p>\n\n\n\n<p> <strong>iii. <\/strong>Initialize the sendgrid object and trigger the mail.<br><br><br><\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.Context;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.LambdaLogger;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.RequestHandler;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.events.SQSEvent;<\/p>\n\n\n\n<p>import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage;<\/p>\n\n\n\n<p>import com.fasterxml.jackson.annotation.JsonProperty;<\/p>\n\n\n\n<p>import com.sendgrid.*;<\/p>\n\n\n\n<p>import org.json.JSONObject;<\/p>\n\n\n\n<p>import software.amazon.awssdk.regions.Region;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.SqsClient;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;<\/p>\n\n\n\n<p>import software.amazon.awssdk.services.sqs.model.SendMessageRequest;<\/p>\n\n\n\n<p>import java.util.Collections;<\/p>\n\n\n\n<p>import java.util.HashMap;<\/p>\n\n\n\n<p>import java.util.Map;<br><\/p>\n\n\n\n<p>public class SendMailToUser implements RequestHandler&lt;SQSEvent, String&gt; {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;@Override<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;public String handleRequest(SQSEvent event, Context context) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (SQSMessage msg : event.getRecords()) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JSONObject respJson = new JSONObject(msg.getBody());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String authorEmail = emailJson.optString(&#8220;authorEmail&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String authorName = emailJson.optString(&#8220;authorName&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String bookId = emailJson.optString(&#8220;bookId&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String bookName = emailJson.optString(&#8220;bookName&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DynamicTemplatePersonalization personalization = new DynamicTemplatePersonalization();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email from = new Email();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String subject = &#8220;Sample Mail trigger, Book Published!&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email to = new Email();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to.setName(&#8220;&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to.setEmail(emailAddress);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addTo(to);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.setSubject(subject);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addDynamicTemplateData(&#8220;subject&#8221;, subject);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addDynamicTemplateData(&#8220;author_email&#8221;, authorEmail);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addDynamicTemplateData(&#8220;author_name&#8221;, authorName);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addDynamicTemplateData(&#8220;book_id&#8221;, bookId);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;personalization.addDynamicTemplateData(&#8220;book_name&#8221;, bookName);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mail mail = new Mail();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mail.setTemplateId(System.getenv(&#8220;dn_template_id&#8221;));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from.setName(&#8220;Refinitiv Customer Notification&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from.setEmail(System.getenv(&#8220;from_email&#8221;));<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mail.setFrom(from);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mail.setSubject(subject);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mail.addPersonalization(personalization);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendGrid sg = new SendGrid(&#8220;SENDGRID_API_KEY&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Request request = new Request();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;Inside sendgrid api call method for user : &#8221; + authorEmail);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.setMethod(Method.POST);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.setEndpoint(&#8220;mail\/send&#8221;);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.setBody(mail.build());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response response = sg.api(request);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(response.getStatusCode());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} catch (Exception e) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(e.getMessage());<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &#8220;success&#8221;;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<br><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;private static class DynamicTemplatePersonalization extends Personalization {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@JsonProperty(value = &#8220;dynamic_template_data&#8221;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;private Map&lt;String, String&gt; dynamic_template_data;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@JsonProperty(&#8220;dynamic_template_data&#8221;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public Map&lt;String, String&gt; getDynamicTemplateData() {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (dynamic_template_data == null) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return Collections.&lt;String, String&gt;emptyMap();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return dynamic_template_data;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void addDynamicTemplateData(String key, String value) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (dynamic_template_data == null) {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dynamic_template_data = new HashMap&lt;&gt;();<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dynamic_template_data.put(key, value);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else {<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dynamic_template_data.put(key, value);<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;}<\/p>\n\n\n\n<p>}<br><\/p>\n\n\n\n<p>Once the implementation of the lambda functions is complete we can upload the code by creating a bundle to their corresponding lambda functions.<\/p>\n\n\n\n<p>Now all the implementation and configurations are done and our service will trigger every 15 minutes, check for the book status and fire an email to the author.<br><\/p>\n\n\n\n<p><strong>Output:-<\/strong><\/p>\n\n\n\n<p>A sample of the mail which we got after event bridge triggers for the first time.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/tgukbv8JW6P0dZI0QnGBqrKskWIKF6shT8lp6uJRYDUMKxCvy9OQx4m5OVzH3ej_TSa8oUiKANIMTb_0XVrKZjaM4LU4L0tUCkr9YrRZbVZN9X8I47Wuc_yrvAFmyugt-6dSb_gpNTt-31NXnCkP3uIHtHHVzv_-Ptne1in2EoIgJuwnY5ZCgeX5x0O5n6DQ\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>By Satyam Chauhan<\/strong><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use case:- Here we are taking a general use case. Let&#8217;s say we have a site where authors can submit [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[333,336,335,338,334,337],"class_list":["post-510","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-aws","tag-eventbridge","tag-lambda","tag-send-email-using-sendgrid","tag-sendgrid","tag-sqs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies\" \/>\n<meta property=\"og:description\" content=\"Use case:- Here we are taking a general use case. Let&#8217;s say we have a site where authors can submit [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\" \/>\n<meta property=\"og:site_name\" content=\"AEM Blog | Lhotse Technologies\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-18T13:19:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-07T06:12:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\" \/>\n<meta name=\"author\" content=\"Shivam Kumar Chauhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shivam Kumar Chauhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\"},\"author\":{\"name\":\"Shivam Kumar Chauhan\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/b8eb4eeb9ca844d32b54de183c946afc\"},\"headline\":\"How to trigger mail dynamically using Sendgrid and Amazon AWS?\",\"datePublished\":\"2022-10-18T13:19:30+00:00\",\"dateModified\":\"2022-11-07T06:12:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\"},\"wordCount\":3949,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\",\"keywords\":[\"aws\",\"eventbridge\",\"lambda\",\"send email using sendgrid\",\"sendgrid\",\"sqs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\",\"name\":\"How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies\",\"isPartOf\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\",\"datePublished\":\"2022-10-18T13:19:30+00:00\",\"dateModified\":\"2022-11-07T06:12:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage\",\"url\":\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\",\"contentUrl\":\"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lhotsetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to trigger mail dynamically using Sendgrid and Amazon AWS?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/\",\"name\":\"AEM Blog | Lhotse Technologies\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lhotsetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#organization\",\"name\":\"AEM Blog | Lhotse Technologies\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png\",\"contentUrl\":\"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png\",\"width\":539,\"height\":172,\"caption\":\"AEM Blog | Lhotse Technologies\"},\"image\":{\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/b8eb4eeb9ca844d32b54de183c946afc\",\"name\":\"Shivam Kumar Chauhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2f5546b9c2e40950ed53a7c2b059fdc37faa2a27d1faa038b2701bba8112e1ad?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2f5546b9c2e40950ed53a7c2b059fdc37faa2a27d1faa038b2701bba8112e1ad?s=96&d=mm&r=g\",\"caption\":\"Shivam Kumar Chauhan\"},\"url\":\"https:\/\/lhotsetechnologies.com\/blog\/author\/shivam\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/","og_locale":"en_US","og_type":"article","og_title":"How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies","og_description":"Use case:- Here we are taking a general use case. Let&#8217;s say we have a site where authors can submit [&hellip;]","og_url":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/","og_site_name":"AEM Blog | Lhotse Technologies","article_published_time":"2022-10-18T13:19:30+00:00","article_modified_time":"2022-11-07T06:12:13+00:00","og_image":[{"url":"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ","type":"","width":"","height":""}],"author":"Shivam Kumar Chauhan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Shivam Kumar Chauhan","Est. reading time":"20 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#article","isPartOf":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/"},"author":{"name":"Shivam Kumar Chauhan","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/b8eb4eeb9ca844d32b54de183c946afc"},"headline":"How to trigger mail dynamically using Sendgrid and Amazon AWS?","datePublished":"2022-10-18T13:19:30+00:00","dateModified":"2022-11-07T06:12:13+00:00","mainEntityOfPage":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/"},"wordCount":3949,"commentCount":0,"publisher":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization"},"image":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage"},"thumbnailUrl":"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ","keywords":["aws","eventbridge","lambda","send email using sendgrid","sendgrid","sqs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/","url":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/","name":"How to trigger mail dynamically using Sendgrid and Amazon AWS? - AEM Blog | Lhotse Technologies","isPartOf":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage"},"image":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage"},"thumbnailUrl":"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ","datePublished":"2022-10-18T13:19:30+00:00","dateModified":"2022-11-07T06:12:13+00:00","breadcrumb":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#primaryimage","url":"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ","contentUrl":"https:\/\/lh5.googleusercontent.com\/6KGTYghSwLkzJP9vMWIEZFSiqVnlBcrDeLKPFdEJLr2bG5rXOX1e89BdiP0XNh6KNzeycOSfKDMmmjJrlkYgq-D1Rc-4tpUXuXwA6SAex43qvjzdusM15oEoMy3SBazKOMtO9oyGsuuwEa0q4q3BqCJ0QR4PRbP4LdFMNKQDiK7MmrXAGQB5okYAw_adx_MQ7Bg3i3C-VQ"},{"@type":"BreadcrumbList","@id":"https:\/\/lhotsetechnologies.com\/blog\/how-to-trigger-mail-dynamically-using-sendgrid-and-amazon-aws\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lhotsetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to trigger mail dynamically using Sendgrid and Amazon AWS?"}]},{"@type":"WebSite","@id":"https:\/\/lhotsetechnologies.com\/blog\/#website","url":"https:\/\/lhotsetechnologies.com\/blog\/","name":"AEM Blog | Lhotse Technologies","description":"","publisher":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lhotsetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lhotsetechnologies.com\/blog\/#organization","name":"AEM Blog | Lhotse Technologies","url":"https:\/\/lhotsetechnologies.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png","contentUrl":"https:\/\/lhotsetechnologies.com\/blog\/wp-content\/uploads\/2019\/07\/lhotse-logo.png","width":539,"height":172,"caption":"AEM Blog | Lhotse Technologies"},"image":{"@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/b8eb4eeb9ca844d32b54de183c946afc","name":"Shivam Kumar Chauhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lhotsetechnologies.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2f5546b9c2e40950ed53a7c2b059fdc37faa2a27d1faa038b2701bba8112e1ad?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2f5546b9c2e40950ed53a7c2b059fdc37faa2a27d1faa038b2701bba8112e1ad?s=96&d=mm&r=g","caption":"Shivam Kumar Chauhan"},"url":"https:\/\/lhotsetechnologies.com\/blog\/author\/shivam\/"}]}},"_links":{"self":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=510"}],"version-history":[{"count":5,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/510\/revisions"}],"predecessor-version":[{"id":527,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/510\/revisions\/527"}],"wp:attachment":[{"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lhotsetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}