Ben Hili
Ben Hili

Reputation: 135

Retrieving fields of email with logic apps / azure function

I have a use case where an HTML form is filled with user data and an email is sent to their email address, CC'ed to a logic app.

The logic app would receive this email and read only the values after name: and email form fields so that I can pass them along to another function.

How would one do this in a logic apps or within an Azure function?

Upvotes: 1

Views: 6067

Answers (1)

Pragna Gopa
Pragna Gopa

Reputation: 726

This blog has great information on using Azure Functions from Logic Apps. Assuming you have the logic app set up to receive emails, you then add a step to process emails in an Azure Function App sending the email content as an input. Sample Input payload to nodejs webhook trigger:

{
  "email": {
    "emailBody": "Body×​​",
    "text": "Hello from Logic Apps"
  }
}

Note: "Bodyx" is the dynamic content representing the email body that was received in an earlier step.

Corresponding index.js in the function app:

  module.exports = function (context, data) {
  var email = data.email;
  // You can now do processing on the emailBody
  context.log('email body', email.emailBody);
  context.res = {
    body: {
      greeting: 'Hello !' + email.text
    }           
  };
  context.done();
};

Hope this helps!

Upvotes: 4

Related Questions