
Using the Data Mapping task, we can extract and assign these values to variables or directly map them to the inputs of the Send Email task.
This enables a fully dynamic, event-driven email workflow — where each email can have customized content, subject, and recipient based on the incoming message.
Click on the Open Data Mapping Editor and begin to define the input. From the local variable section, expand the CloudPubSubMessage, drag and drop the data varible as the first input.
Now to extract the custom variable, drag and drop the attributes from CloudPubSubMessage, once its there click on the + sign and select GET_PROPERTY method.
Repeat the same for extracting the email subject attribute as well. now we will define the Output variables. On the first one CloudPubSubMessage.data, click on create a new one named emailBody
While creating the output variable, select the variable type as Output from Integration and data type as String. Repeat the same for recipient and subject as well.
At this point in time, you should be seeing 3 variable on the Outputs section like this.
Now that we’ve extracted the necessary values using the Data Mapping task, we’re ready to configure the Send Email task to deliver the email using those values.
🧩 Add the Send Email Task
From the Tasks panel, drag and drop the Send Email task into your integration flow, following the Data Mapping step.
✉️ Configure the Task Inputs
Map the fields in the Send Email task to the variables you extracted earlier:
- To: Use the variable holding the recipient’s email, extracted from
attributes.email_id_1
. - Subject: Use the variable holding the email subject, extracted from
attributes.subject
. - Body: Map this to the variable holding the main message body, extracted from the
data
field of the Pub/Sub message.
At this time your integration would look like this, and make sure that we are connecting the each tasks (configure edge). basically drag and drop to connect the tasks.. at this time we should be ready to test.. take the json payload, click the Test button from the right top..
Click on the test integration, with that you should get email delivred to your target email..
Here’s a cleaner and more professional wrap-up for your article, while keeping the tone friendly and encouraging:
Source Credit: https://medium.com/google-cloud/automating-email-workflows-with-google-cloud-application-integration-pub-sun-and-send-mail-task-74be78e414c1?source=rss—-e52cf94d98af—4