Hello!
We receive airfare emails for our event attendees. Because I do not have AI Builder, I am pulling the information from the email body instead of from the attached Airfare Invoice. The goal is to rename the invoice with specific information. I have been able to successfully do this in all but one scenario through a series of Compose actions and a Filter Array.
Current flow searches for the word "Destination:" and returns what comes after it. This works great, unless the person has a layover. I need the final destination of the outbound trip pulled in order to rename the attached PDF correctly.
1.) When a new email arrives...
2.) HTML to Text
a. triggerOutputs?()['body/body']
3.) Initialize Variable
a. Type = String
b. body('Html_to_text']
4.) Compose - Find Destination
a. substring(variables('varEmailBody'), add(indexOf(variables('varEmailBody'), 'Destination:'), 12), sub(length(variables('varEmailBody')), add(indexOf(variables('varEmailBody'), 'Destination:'), 12)))
5.) Compose - New Line
a. //carriage return
6.) Compose - Split Destination Lines
a. split(outputs('Compose-Find Destination'), outputs('Compose-newline'))
7.) Filter Array - Destination
a. From: Outputs['Compose - Split Destination Lines']
b. Filter Query: length(trim(item())) is greater than 0
8.) Compose - Destination Line
a. body('Filter_array_Destination')?[0]
9.) Compose - Destination Final
a. trim(split(outputs('Compose - Destination Line'),',')[0])
Assuming the below itinerary is in the body of the email, the flow would pull New York. How do i get it to pull Destination 1 (New York) when there is no layover, and Destination 2 (Boston) when there IS a layover? Keeping in mind that the return flights are also in this email body, so there would be (a) return Destination(s) that should not be taken into account.
|
9:00AM |
|
Flight Information
Carrier: Delta Air Lines Inc
Flight: DL 12345
Class: Economy
Origin: Los Angeles, CA
Departing: Monday 09 December 2024 at 9:00AM
Destination: New York, NY, New York LaGuardia Apt (LGA)
Arriving: Monday 09 December 2024 at 10:45AM |
|
12:00AM |
|
Flight Information
Carrier: Delta Air Lines Inc
Flight: DL 54321
Class: Economy
Origin: New York, NY, New York LaGuardia Apt (LGA)
Departing: Monday 09 December 2024 at 12:00AM
Destination: Boston, MA, Boston Edward L Logan Intl Apt (BOS)
Arriving: Monday 09 December 2024 at 1:20PM |
Would appreciate any help you can provide!