How to convert data from email to JSON in Power Automate - power-automate

I'm trying to user Power Automate to get data from a new incoming mail and convert it to JSON(to a file) and then work with it in C#. Unfortunately I have never worked with Power Automate. This is my first test, but it doesn't work because of the input, but I did everything according to the instructions here
This is tutorial I've followed: https://www.youtube.com/watch?v=62BB3rpe37g
The inputs of Split Body Text is
split(body('Html_to_text',outputs('EnterKey')))

Okay, after getting the required information, it's actually fairly easy:
You misplaced a bracket. It should be
split(body('Html_to_text'),outputs('EnterKey'))
within your Split Body Text node. body takes a single argument.
On a side note:
This EnterKey node is not really required. You could drop this and replace the outputs('EnterKey') with a simple '\r\n'.

Related

JMeter - PDF Conversions Produces Blank PDF's

I know there are similar articles like PDF file conversion in JMeter but they do not answer the actual problem which is "when converting a PDF to a variable/object/property then back to PDF the document whilst the correct number of pages is 'whit on white'= blank.
is there a way to :
Create a runtime variable/object/property from an existing PDF file that can be used in a subsequent action.
Here other actions happen in the Test Plan but they do not
Convert the variable/object/property back to a pdf so that when viewed it does not contain just blanks.
Notes: I do not just wish to just copy a to pdf to pdf.
I have also tried creating a UDV form the pdf using the following posted on here without success too.
${__groovy(vars.putObject("hoping_its_a_pdf"), new File("my_original.pdf"))}
Reading other posts here I have also noticed strange character strings like "%âãÏÓ" when using both putObect and props.put when viewing them post creation but as the article said, most probably page break characters or similar so I have ignored those for now as I assumed it is the conversion and not the reason for the blank content.
Can someone please assist as this is now 4 weeks in and I still have white pdf's.
We cannot state what's wrong with the code which you're copying and pasting from some random sources.
There is not problem with storing the PDF file in JMeter Variables or properties and creating the file back from them.
Demo:
There are 2 problems the only piece of "code" you're sharing:
Your way of using vars.putObject() function is wrong, it takes 2 parameters: variable name and the object value. See Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on this and other JMeter API shorthands
Apart from this the function itself is syntactically incorrect, you need to escape any comma in the function with a backslash
So if you change your:
${__groovy(vars.putObject("hoping_its_a_pdf"), new File("my_original.pdf"))}
to
${__groovy(vars.putObject('hoping_its_a_pdf'\, new File('my_original.pdf')),)}
at least this bit will start working as you expect.

How does file convertors work in general like word to pdf, XML to json, word to txt etc

I've used many types of file convertor like word to pdf, XML to json, word to txt etc.
How do they work in backend? Is there some specific guidelines each of them follow? Are there some similarity in the way they are implemented.
I tried searching it but most of the articles take me to the web app that can convert the doc, but none of them gives clarity on how it's done.
All of them work by parsing the first document into a data structure. Then generate a document in the other format from that data structure using recursion.
Parsing itself is a giant topic that people take courses on in computer science. But long story short, it proceeds by breaking the document into tokens, and then fitting the tokens into a parse tree using one of a standard set of methods. They have all sorts of fancy names like Recursive Descent and LALR(1). That's where most of the theory you'd want to learn is.
For example if you're writing a JSON to XML converter, you'd first need to parse that JSON. A JSON Parser shows how you could write that, from scratch, using recursive descent. Once written you just need to write a recursive function that takes each data type and does something appropriate with it to generate text in the format that you want.
Incidentally you can also write a "document converter" that converts from a document format to the same document format. Why would someone want to do that? The two most common use cases are to prettify or minify code. Despite the fact that only one format is being dealt with, the principles of how you do it are exactly the same.

Extract data from outlook

I've got many emails with the same format as shown in the screenshot above: Finished Product, Material Description and Assembly Location. Is there a way to extract specific data from an email? As seen from the screenshot above (the body of the email in outlook), I would like to get the result for Material Description; which in this case is Nike and paste over into an excel file.
That's pretty easy. First the overlook:
Now let's brake it down to the important parts so you can follow it way easy.
You need to following variables:
The Get Mail Messages activity works best when you already have Outlook installed. If so take that:
In the For Each activity you set the Type to MailMessage
In the Regular expression activity called Matches you go into the item.Body and matching all Material Description: (.+) occurrences.
And finally you do anything you want with the found matches. Make sure to use another for each here if you have more than one match. If not it's the easiest way to access the occurrence with Matches(0).toString and before check if there is any match given:

How to create a character counter bot in api.ai?

I'm an absolute knob when it comes to programming, so I ask of your help.
Essentially I'm trying to use the api.ai interface to create a character counter (in slack) where when a user says something like "hi" the bot will respond with "2".
So far I understand that I'm supposed to use an entity in order to achieve this transformation, and I have tried mapping reference words like "hi" with the synonym "2". However, the entity transformation ends up having the bot spew out exactly what the user initially said (ex. "hi"), instead of my desired outcome ("2").
Am I going about this wrong, or am I supposed to use an already existing entity to in my new entity? I apologize in advance as I literally picked this thing up yesterday, so I don't know much about it.
Any help is appreciated!
You cannot write logic in api.ai, meaning you cannot write a function that takes as input a message and returns the number of characters.
What you would need, I believe, is to integrate the api.ai with an external web service where you can write your business logic.
Have a look at Slack + Webhook Integration Example https://docs.api.ai/docs/slack-webhook-integration-guideline
However, if you just want to count the number of chars in a message, I do not see the need for api.ai.

How do I take each line of a text file and insert them into a web form? Specifically, for testing domain name availability

I wrote a Ruby script that appended "data" to the beginning of every word of the English dictionary, and then filtered out various strings using different parameters, and now I want to use a site like namecheap or gandi.net in order to take each of these strings and insert them into the domain name availability checker in order to determine which ones are available.
It is my understanding that this will involve making a POST HTTP request of some kind, as well as grabbing the element in question, but I don't really understand the dynamics of what to read about in order to do this kind of thing.
I imagine that after a few requests I will be limited, but as a learning exercise I am still curious as to how I would go about doing this.
I inspected the element (on namecheap) to see what the tag looked like, to find any uniquely identifiable class/id names that I could use to grab that specific part of the source, and found that inside a fieldset tag, there was a line of HTML that I can't seem to paste here, so here is a picture:
Thanks in advance for any guidance in helping me learn about web scripting!

Resources