How do I insert a dynamic value of Request Body (URL) to call an Azure Function?

King Java 790 Reputation points
2024-11-06T00:13:06.7066667+00:00

This is possibly my 5th time posting a thread in Microsoft Q & A.

This is a new post after a Microsoft engineer suggested to create a new thread after we could not figure out.

This is previous post:

https://learn.microsoft.com/en-us/answers/questions/2105092/how-to-extract-url-from-email-body-using-javascrip

What I initially tried to do was, inside Azure Logic App, I used "Execute JavaScript Code" step to extract particular URL from previous step (Get emails (V3).

User's image

Bottom is details inside "Execute JavaScript Code" step:

User's image

But, it appears that that would not work, so the Microsoft engineer tried using "Call an Azure Function" to call an Azure Function that contains JS node code that has a logic.

Bottom is logic inside that Azure Function.User's image

Now, I am stuck how to express inside "Request Body" of "Call an Azure function".

The value inside the "Request Body" has to be dynamic as it changes daily.

User's image

When I ran this, it ran without error (as shown on the bottom image), but now, I need to modify the "Request Body" area to call the Azure Function with a dynamic value (after "details= ").

User's image

How do I express that (inside "Request Body")?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,543 questions
{count} votes

Accepted answer
  1. Khadeer Ali 5,990 Reputation points Microsoft External Staff Moderator
    2024-11-08T01:53:13.3633333+00:00

    Hi King Java,

    As discussed, to achieve your requirement, you can follow the steps below in your workflow:

    1. Outlook Trigger: Use the "When a new email arrives (V3)" trigger. This will monitor all incoming emails in a specified folder within your inbox, based on the conditions you set.
    2. Execute JavaScript Code Action: Use the "Execute JavaScript Code" action with the following regex expression and JavaScript code to extract any http or https links present in the email body. Here’s the inline JavaScript code you can use:
    var text = /https?://\S+/g;
    
    var links = workflowContext.trigger.outputs.body.body.replace(/https://nam06.safelinks.protection.outlook.com[^"]+/g, '');
    
    var result = links.match(text);
    
    if (result && result[0]) {
    result[0] = result[0].replace(/"$/, '');
    }
    
    return result[0];
    
    
    

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.