Enable Dialogflow ES Sentiment Analysis by API - dialogflow-es

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.

Related

How To Pass Multiple Files in Binary Format in Form Data in Azure Logic App HTTP

i am trying to pass two files in multipart form in the Azure Logic App in binary format. But the upload request gets reject. When i pass the same request in postman, the request is successful. PFB the details.
Postman Request:
Header:
Postman Curl Request:
curl --location --request POST 'https://abc/kofax/claims' \
--header 'x-abchk-msgid: 0214945a-509a-48af-9df2-281352806421' \
--header 'Content-Type: multipart/mixed' \
--header 'Authorization: Bearer XXXXXXXXX' \
--form 'claimScanPDF=#"/C:/Users/ashutosh.bajpai/00000438.PDF"' \
--form 'claimScanJSON=#"/C:/Users/ashutosh.bajpai/kofax-op.json"'
Azure Logic App:
--testboundary
{
"$content-type": "multipart/mixed",
"$multipart": [
{
"body": #{concat(body('GETFILEPDF').$content)},
"headers": {
"Content-Disposition": "form-data; name:claimScanPDF; filename=#{triggerBody()?['FileNamePDF']}"
}
},
{
"body": #{concat(body('GETFILEJSON').$content)},
"headers": {
"Content-Disposition": "form-data; name:claimScanJSON; filename=#{triggerBody()?['FileNameJSON']}"
}
}
]
}
--testboundary--
i only get generic error message in response - The requested URL was rejected. Please consult with your administrator.
Please help to understand what is the difference between postman and logic app request.

Getting "The body you sent contains an unknown key." when trying to create a Contentful entry

I have created a contentful model called "User" with two fields:
id - text, unique, required
email - text, optional
When I try to create a new entry via content management API using these parameters:
Headers:
X-Contentful-Content-Type : user
Content-Type : application/vnd.contentful.management.v1+json
Method
PUT
URL
https://api.contentful.com/spaces/qilo7tiaixh8/environments/entries/
Body:
{
"id":"whatever",
"email": "peter#petervukovic.com"
}
I get the following error:
{
"requestId": "2849bbcd7ee0486bb36b47927071f37b",
"sys": {
"type": "Error",
"id": "UnknownKey"
},
"message": "The body you sent contains an unknown key.",
"details": {
"errors": [
{
"keys": [
"id",
"email"
]
}
]
}
}
I have no idea what I'm doing wrong as the examples in the official documentation aren't helpful (they assume multi-lingual content I'm not using) and there are no debugging hints.
Contentful DevRel here. 👋
I just tried it and the following CURL works for me on a user content type that defines a title field.
curl --include \
--request PUT \
--header 'Authorization: Bearer ...' \
--header 'Content-Type: application/vnd.contentful.management.v1+json' \
--header 'X-Contentful-Content-Type: user' \
--data-binary '{
"fields": {
"title": {
"en-US": "Hello Test"
}
}
}' \
https://api.contentful.com/spaces/.../environments/master/entries/\test-1
It looks like you were missing to include the fields property in your payload. About the localization part, I think it's required to provide the locale for your field values. So in my example, en-US is the default value and it is required.
For using PUT you have to define or come up with an entry id.
To create an entry without passing and defining an id have a look at the docs in Entry collection.
curl --include \
--request POST \
--header 'Authorization: Bearer ...' \
--header 'Content-Type: application/vnd.contentful.management.v1+json' \
--header 'X-Contentful-Content-Type: user' \
--data-binary '{
"fields": {
"title": {
"en-US": "Hello Test 2"
}
}
}' \
https://api.contentful.com/spaces/.../environments/master/entries/

Beginner Question - Google Natual Language Processing API Key & URL

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
}
}
]
}

How to post data to kobotoolbox form using the Kobo API?

I'm working with the kobo REST API and I can get the structure's information from the form and the submitted data through the API, but when I try to send data to the form through a POST service, kobo returns the following message: "Your data for instance None has been already submitted.".
Is there any way to send POST data to a kobotoolbox form using its API?
I tried to send the data with the following POST request:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"name": "Foo" \
}' 'https://kf.kobotoolbox.org/assets/{form_id}/submissions/'
Where {form_id} is the id from my form in kobotoolbox
And the response was:
{
"detail": "Your data for instance None has been already submitted."
}
To submit data you need to POST to https://[kobocat url]/api/v1/submissions, e.g. https://kc.kobotoolbox.org/api/v1/submissions. The endpoint you tried is for retrieving submitted data.
This will work (for a form that contains a first_name and last_name question:
curl -X POST \
https://kc.kobotoolbox.org/api/v1/submissions.json \
-H 'Authorization: Token <yourAPItoken>' \
-H 'Content-Type: application/json' \
-d ' {
"id": "<kpi asset ID>",
"submission":
{
"last_name": "Suresh",
"first_name":"Ameen",
"meta": {
"instanceID": "uuid:8992c3c2-3418-4ba9-a8e2-b00e03ea36b6"
}
}
} '
<kpi asset ID> in this case refers to the unique form ID created in kobocat. This ID should be the same as the kpi asset ID, as long as you uploaded/created your form in the regular interface and deployed it.
You can find the ID by going to https://kf.kobotoolbox.org/assets/<kpi asset ID>/. In my case I get this:
{
"url": "https://kf.kobotoolbox.org/assets/aCNoKPdCX8gqcu4bHrHkUL/",
...
"deployment__identifier": "https://kc.kobotoolbox.org/<username>/forms/aCNoKPdCX8gqcu4bHrHkUL",
...
"uid": "aCNoKPdCX8gqcu4bHrHkUL",
]
}

Dialogflow v2 REST call returns 400 Bad Request

I get a 400 Bad Request when issuing this entityTypes.create call:
wget --header="Authorization: Bearer ${TOKEN}" \
--post-data=' { "displayName": "writer1", "kind": "KIND_MAP", "autoExpansionMode": "AUTO_EXPANSION_MODE_DEFAULT", "entities": [ { "value": "Virginia Woolf", "synonyms": [ "Virginia Woolf" ] } }' \
https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes
but this -- entityTypes.list -- works OK:
wget --header="Authorization: Bearer ${TOKEN}" \
https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes
Any ideas? Thanks.
By default, --post-data uses a content-type of application/x-www-form-urlencoded. The API requires the content-type of application/json.
I tend to use something more like
wget \
--header="Authorization: Bearer ${TOKEN}" \
--header="Content-type: application/json" \
--post-data='{ ... }' \
https://dialogflow.googleapis.com/v2/projects/MyProject/agent/entityTypes

Resources