Beginner Question - Google Natual Language Processing API Key & URL - google-cloud-nl

I'm a nursing student trying to use the NLP API to understand what hospital patients are saying about their experience. I'm trying to use the NLP API in Microsoft's Power Automate via their HTTP connector option but I don't know how to correct configure the connector.
Google's documentation page shows the following example:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'encodingType': 'UTF8',
'document': {
'type': 'PLAIN_TEXT',
'content': 'Enjoy your vacation!'
}
}" "https://language.googleapis.com/v1/documents:analyzeSentiment"
https://cloud.google.com/natural-language/docs/analyzing-sentiment#language-sentiment-string-protocol
I have a API key that works but I'm unsure of how to pass it into Microsoft's HTTP connector.
Microsoft HTTP Connector
How do I set the connector up to call the Google Natural Language API and return the sentiment score?
Google's documentation shows this as a successful return:
{
"documentSentiment": {
"magnitude": 0.8,
"score": 0.8
},
"language": "en",
"sentences": [
{
"text": {
"content": "Enjoy your vacation!",
"beginOffset": 0
},
"sentiment": {
"magnitude": 0.8,
"score": 0.8
}
}
]
}

Related

Enable Dialogflow ES Sentiment Analysis by API

How can I enable "Sentiment Analysis" on a Dialogflow Essentials agent through an API request?
You may enable Dialogflow ES Sentiment Analysis by providing sentimentAnalysisRequestConfig field in the Request JSON body of your API request and setting the analyzeQueryTextSentiment to true similar to below sample testing.
Sample request.json:
{
"queryParams": {
"sentimentAnalysisRequestConfig": {
"analyzeQueryTextSentiment": true
}
},
"queryInput": {
"text": {
"text": "please reserve an amazing meeting room for six people",
"languageCode": "en-US"
}
}
}
Sample API request via cURL command:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d #request.json \
"https://dialogflow.googleapis.com/v2/projects/project-id/agent/sessions/123456789:detectIntent"
Output:
You may refer to this Dialogflow ES - Detect Intent documentation for more details.

Is there a function to list all SPL Tokens in a Wallet using Rust

Is there a function which can get a list of all tokens a wallet owns using Rust?
There is an JsonRPC EndPoint on Solana : getTokenAccountsByOwner
Returns all SPL Token accounts by token owner.
https://docs.solana.com/developing/clients/jsonrpc-api#gettokenaccountsbyowner
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getTokenAccountsByOwner",
"params": [
"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F",
{
"mint": "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"
},
{
"encoding": "jsonParsed"
}
]
}
'
I also think there is a way to make calls to endpoints from smart contracts, you should look around for this

Creating invoices in bulk using NetSuite REST API

Is there a way to create multiple invoices with a single POST request to the NetSuite REST API?
The API Reference doesn't mention anything - but I'm hoping there's a way to avoid sending thousands of individual requests.
I am creating a single invoice like this (some headers have been removed):
curl --location --request POST 'https://{{COMPANY_URL}}.suitetalk.api.netsuite.com/services/rest/record/v1/invoice' \
--header 'Content-Type: application/json' \
--data-raw '{
"entity": {
"id": 46
},
"item": {
"items": [
{
"item": {
"id": 134
},
"amount": 20
}
]
}
}'

How to annotate System Entities in Dialogflow API?

We are using the Dialogflow API to export entities into Dialogflow.
We cannot use the console because we would need to do it for each customer and it is complicated.
We would like to use system entities though but I cannot manage to find how to do that in the documentation.
https://cloud.google.com/dialogflow/es/docs/reference/rest/v2/projects.agent.intents?hl=fr#Intent.TrainingPhrase
Thanks for the help !
As Per your Requirement, you want to add system entities to your Training Phrases through the DialogFlow API and export it to the DialogFlow console. You can achieve this by following the below steps-
1-You have to create an Intent Json file where you need to Provide your Intent and in Training Phrases you will Provide your Training Phrase texts.
For example - if your training phrase is “I speak french and my Address is CDA,sec-9”, you have to break the sentence into parts as DialogFlow API does not automatically annotate training Phrases as Dialogflow Console does.
Do not forget to add Whitespaces after each Text Part.
{
"displayName": "details",
"priority": 500000,
"webhookState": "WEBHOOK_STATE_UNSPECIFIED",
"trainingPhrases": [
{
"name":"",
"type": "EXAMPLE",
"parts": [
{
"text": "I speak "
},
{
"text": "French",
"entityType":"#sys.language",
"alias": "language",
"userDefined": "True"
},
{
"text" : " and My address is "
},
{
"text" : "CDA,SEc-10",
"entityType":"#sys.location",
"alias": "address",
"userDefined": "True"
}
]
}
],
"action": "details",
"messages": [
{
"text": {
"text": [
"Here are my details"
]
}
}
]
}
You can add those system entities which are extendable only as per the doc.
After creating the Json file Use the below Command to export intent with training Phrases to DialogFlow console via DialogFlow API.
Note: You need to add your project id in <project-id> field.
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d #intent.json \
https://dialogflow.googleapis.com/v2/projects/<project-id>/agent/intents?key=[YOUR_API_KEY]

api call to upload an image to object storage container on bluemix node js app

Iam trying to upload an image to object storage container and get the url of that image deployed on bluemix using a node js app.To achieve this i need to use a post or put api call.I could able to authenticate with the object storage but not able to achieve the functionality through the api calls.So,I need some help on the api calls.So can some one help me out in this if you had worked on such kind of api calls with images on object storage.(using object-storage npm).Even share any kind of sample working api calls.Any help appreciated.
Object storage api's are derived from the OpenStack Swift API spec. In order to add an object of any sort to a Bluemix Object Storage container, you'll need to do 2 things:
Authenticate to the Object Storage instance to obtain an authorization token.
Perform actions on the container using the token obtained.
I assume that you already have access to the JSON credentials provided by the object storage service ... similar to:
{
"auth_url": "https://identity.open.softlayer.com",
"domainId": "nice_long_hex_value",
"domainName": "some_number",
"password": "not_gonna_tell_you",
"project": "object_storage_hex_value",
"projectId": "project_hex_value",
"region": "dallas",
"userId": "another_fine_hex_value",
"username": "some_text_with_hex_values"
}
Step 1: Obtain X-Auth-token. 4 items (user_id, user_name, password and auth_url) should come from your provided credentials.
curl -i -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"id": "another_fine_hex_value",
"password": "not_gonna_tell_you"
}
}
},
"scope": {
"project": {
"id": "project_hex_value"
}
}
}
}' "{auth_url}/v3/auth/tokens" | tee response.txt | grep X-Subject-Token | sed 's/.*X-Subject-Token: \([^ ]*\).*/\1/g' | tee >(awk '{printf("\nX-Auth-Token: %s\n\nJSON Response Body:\n", $0)}' > /dev/tty) | sed -n '/{/,$p' <response.txt | python -m json.tool && rm response.txt
This should result in a 500+ Line JSON Response BODY (take note of the public interface for the region of dallas within the swift endpoints array) similar to …
{
"token": {
"methods": [
"password"
],
"roles": [
{
"id": "redacted",
"name": "ObjectStorageOperator"
}
],
"expires_at": "2016-03-09T20:26:39.192753Z",
"project": {
"domain": {
"id": "some_hex_value",
"name": "some_int"
},
"id": "another_hex_value",
"name": "one_more_hex_value"
},
"catalog": [
...
{
"endpoints": [
{
"region_id": "london",
...
},
{
...
},
{
"region_id": "dallas",
"url": "https://dal.objectstorage.open.softlayer.com/v1/AUTH_",
"region": "dallas",
"interface": "public",
"id": "some_unique_id"
},
{
...
},
{
...
},
{
...
}
],
"type": "object-store",
"id": "hex_values_rock",
"name": "swift"
},
...
],
"extras": {},
"user": {
"domain": {
"id": "hex_value",
"name": "another_fine_int"
},
"id": "tired_of_hex_values_yet?",
"name": "cheers_one_more_hex_value_for_the_road"
},
...
}
}
Specifically, we want to identify the Swift Object Storage API url in the form:
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value
https://dal.objectstorage.open.softlayer.com/v1/AUTH_some-hex-value is
linked to your desired object storage region (dallas, london, …) and associated with a public interface. This will be found within the endpoints section which includes the name “swift”.
Even more importantly, within the generated HTTP Response Header of this /v3/auth/tokens call is an authentication token that we also need to record to facilitate subsequent authenticated HTTP API calls.
Here is a sample of the HTTP Response Headers
Connection: Keep-Alive
Content-Length: 12089
Content-Type: application/json
Date: Wed, 09 Mar 2016 19:26:39 GMT
Keep-Alive: timeout=5, max=21
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_wsgi/3.4 Python/2.7.5
Vary: X-Auth-Token
X-Subject-Token: gAAAAABW4Hjv5O8yQRwYbkV81s7KC0mTxlh_tXTFtzDEf3ejsP_CByfvvupOeVWWcWrB6pfVbUyG5THZ6qM1-BiQcBUo1WJOHWDzMMrEB5nru69XBd-J5f5GISOGFjIxPPnNmEDZT_pahnBwaBQiJ8vrg9p5obdtRJeuxk7ADVRQFcBcRhAL-PI
x-openstack-request-id: req-26a078fe-d0a7-4a75-b32d-89d3461c55f1
The X-Subject-Token is the important response header. Its value will be reused within all subsequent HTTP Request Headers using the header X-Auth-Token. Obvious, right?
Step 2: With this token, let's add an object to a container named "ibmjstart".
curl -s -X PUT -i -H "Content-Type: text/plain"\
-H "X-Auth-Token: X-Subject-Token from above"\
-H "Cache-Control: no-cache"\
-d "Awesome sauce is best served warm" "{API AUTH URL obtained above}/ibmjstart/test.txt"
If all goes well, this should result in a new container named ibmjstart which contains a text file named test.txt with a single line of content.

Resources