Microsoft Translator API 3.0 to HTML - azure

is it possible to use microsoft translator text api 3.0 and return html instead of json. Right now I can input html and it will be returned into the json like this:
Input:
<div>hi</div>
Output:
[ { "translations": [ { "text": "
Ciao</div>", "to": "it" } ] } ]
Desired result:
Input:
<div>hi</div>
Output:
<div>Ciao</div>
Would really appreciate any help I can get on this.

In the Translate method of Microsoft Translator API 3.0, there is the following textType parameter:
By default, the API method is considering your text as plain text. Add this parameter with html value and the result will not drop the <div> like in your question

Related

How can I send documents with http request to power automate?

How can I send array documents and images with an HTTP request to power automate?
I am using type script with nodejs as backend.
Please see the code I am using below:
Services.ts:
sendEmailData( Notice_ID: string, Site_Notice_ID: string,EmailAddress:
string,Issued_To: string,Issue_To_Email: string,Description: string,Documents: any){
const postData: Post = {Notice_ID:Notice_ID, Site_Notice_ID:
Site_Notice_ID,EmailAddress: EmailAddress,Issued_To:Issued_To,
Issue_To_Email: Issue_To_Email,Description:Description, Documents: Documents};
this.http.post(this.SendEmailUrl, postData).subscribe(responseData => {
console.log(responseData)
});
}
Component.ts:
sendEmail(){
// console.log(emailData)
let Description = (document.getElementById("input2") as HTMLInputElement).value
this.postsService.sendEmailData(
emailData.Notice_ID,
emailData.Site_Notice_ID,
emailData.EmailAddress,
emailData.Issued_To,
emailData.Issue_To_Email,
Description,
this.Documents)
}
Power automate HTTP received sample:
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [
{},
{},
{}
]
}
You wanna send documents to PWA flow, right? What is the origin format and what format do you want to save these documents in? Where do you want to save them?
I'm considering you want to send them to PWA by a post request and save it in a OneDrive Business' folder.
{
"Notice_ID": "39208101",
"Site_Notice_ID": "392081",
"EmailAddress": "some#emailaddress.co.za",
"Issued_To": "Jay",
"Issue_To_Email": "some#emailaddress.co.za",
"Description": "",
"Documents": [ {"$content-type":"application/pdf","$content":"your base64 encoded
file here"}]
}
You can take a look at the complete example: https://api.npoint.io/073b1351d9b0cd0c7f88
Then, add the key "Documents" to a variable, like this:
Create an "apply to each" action to run your "documents" list.
For each dictionary in your document list, create a file:
In the "file content" field you can put the "Current action" variable.
Don't forget to create a counter or find some other way to name your created files with different names. You can also bring them named from your application and use the JSON body below:
"Documents": [ {"filename":"myfile.pdf","file":{"$content-
type":"application/pdf","$content":"your base64 encoded
file here"}}]
And set the filename in the "Apply to each":
Change the "file content":
You can use this website for generating base64 encoded files for testing your flow: https://base64.guru/converter/encode/pdf

Parse values from the JSON returned by URL of Google Place API

I am creating a bot using dialogflow-fulfillment, and I am using Google Place API to pull additional information about hospitals.
I have made a dummy response, for the sake of example, that is returned by Google Place API, here is the link: http://www.mocky.io/v2/5c2b9f9e3000007000abafe3
{
"candidates" : [
{
"formatted_address" : "140 George St, The Rocks NSW 2000, Australia",
"name" : "Museum of Contemporary Art Australia",
"photos" : [
{
"height" : 3492,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/105784220914426417603/photos\"\u003eKeith Chung\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAaGaCX-kivNEaJ-z97AduTYgW3d98uv53-8skNrS1k1GTgOtiQ1-Z2gfWJydrpkrshuV_kHPKizl088dezEJgIxYGoTWqtJgah-u_I46qNNYMfUbk8LKBZqxzkHyIL1nWEhBO6lPa0NgvlyLGBrXpXFPUGhT0lAUj_oCiOWV2MEYdBeKf-kTtgg",
"width" : 4656
}
]
}
],
"status" : "OK"
}
I need to parse values of my choice from the JSON returned by Google Place API. For example, If I had to parse value of 'name' from the JSON above using Python, I would do this:
import requests, json
api_key = ''
r = requests.get('https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name&key=' + api_key)
x = r.json()
y = x['candidates']
print(y[0]['name'])
Above code for the job is lucid and works perfectly. Considering my inexperience in Nodejs, would you please let me know something similar in Nodejs to parse the value, for instance, the value of 'name'?
Your valuable reply will encourage me.
P.S: Humbly, the question involves first making a call to Google Place API and then parsing values from the returned JSON. Please follow the steps given in Python code above for better understanding.
Get the API response in an async HTTP request (there are tons of npm libraries like request to help you automatically set headers etc), then use standard library JSON.parse(body) to get an plain JavaScript object which contains a structured representation of the API response.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

Send back rich responses to Actions on Google through Dialogflow webhook fulfillment

To get Google Assistant to display rich responses to the user, one must provide it with a response like the example on the Actions on Google docs. However, since I'm using Dialogflow as the intermediary party between my server and Google's, I need to provide some kind of response to Dialogflow in my webhooks to indicate that there should be a rich response. As you can see from that link, the docs mention how to send rich responses to FB Messenger, Kik, LINE, etc. but not Google Assistant.
What am I missing here? I see an option for rich responses in the Dialogflow web console, but there I can only seem to input hardcoded responses with no dynamic data from the server. What's the right way to do this?
Using the Dialogflow integration, the response JSON your webhook should return for a rich response will look like:
{
"data":{
"google":{
"expectUserResponse":true,
"noInputPrompts":[
],
"richResponse":{
"items":[
{
"simpleResponse":{
"textToSpeech":"Welcome to this Basic Card",
"displayText":"Welcome to this Basic Card"
}
},
{
"basicCard":{
"buttons":[
{
"title":"Button Title",
"openUrlAction":{
"url":"https://some.url"
}
}
],
"formattedText":"Some text",
"image":{
"url":"http://some_image.jpg",
"accessibilityText":"Accessibility text describing the image"
},
"title":"Card Title"
}
}
],
"suggestions":[
{
"title":"Aléatoire"
},
{
"title":"Top"
}
]
}
}
}
}
If you are using the Node.js library You can also use the provided methods for Dialogflow integration to build your rich response.
If you're using Node.js you should call the method buildRichResponse() and then add items as child of that object, like this:
app.ask(app.buildRichResponse()
.addSimpleResponse('A text to be spoken')
.addBasicCard(app.buildBasicCard('Some text to be displayed')
.setTitle('A title')
.addButton('Read more', 'https://example.google.com/something')
.setImage('https://example.google.com/image.png', 'Image alternate text')
.setImageDisplay('CROPPED')
)
);
That was an example for adding a BasicCard, you can see how to add Carousels, Lists and Suggestions Chips at https://developers.google.com/actions/assistant/responses#rich-responses

Outlook REST API to extract URLs in the message body

Is there an Outlook REST API that gives me all the urls extracted from the body of the message? Some thing like what EWS's EntityExtractionResult does?
No there isn't. However, you can retrieve extended properties, so you should be able to request the PidNameExtractedUrls property.
If you dig through those open specs, you should find these details on PidNameExtractedUrls:
Property set: PSETID_XmlExtractedEntities {23239608-685D-4732-9C55-4C95CB4E8E33}
Property name: XmlExtractedUrls
So that would mean I could make the following request (assuming you're using the Outlook endpoint, not Graph):
GET https://outlook.office.com/api/v2.0/me/messages?$expand=SingleValueExtendedProperties($filter=PropertyId eq 'String {23239608-685D-4732-9C55-4C95CB4E8E33} Name XmlExtractedUrls')
For Graph, you would replace PropertyId with id.
That will include something like this in the message entities that have this property set:
"SingleValueExtendedProperties": [
{
"PropertyId": "String {23239608-685d-4732-9c55-4c95cb4e8e33} Name XmlExtractedUrls",
"Value": "<?xml version=\"1.0\" encoding=\"utf-16\"?><UrlSet><Version>15.0.0.0</Version><Urls><Url StartIndex=\"0\"><UrlString>https://www.google.com</UrlString></Url><Url StartIndex=\"23\"><UrlString>https://developer.microsoft.com/outlook</UrlString></Url></Urls></UrlSet>"
}
]

Is there a way to search inside a message using Gmail API?

I have thousands of email. I need to search whether any of the message contains the text "Hello world" or any other regular expression. How can I achieve this using Gmail API?
The Users.messages: list-request supports a custom query parameter that you can use. This parameter works just the same as the search input field in the regular Gmail Client.
q = Hello world
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=Hello+world
Response:
{
"messages": [
{
"id": "14f9826d5e0811ee",
"threadId": "14f9826d5e0811ee"
}
],
"resultSizeEstimate": 1
}

Resources