ORIGINAL REQUEST: I'm trying to implement the push notifications following the documentation: https://developers.google.com/actions/assistant/updates/notifications
I'm using Dialogflow with webhooks (in PHP) and the documentation is giving example in nodeJS
Right now, i'm blocked because of the Update permission, here's my Webhook response :
{
"source": "webhook",
"payload": {
"google": {
"expectUserResponse": true,
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"permissions": [
"UPDATE"
]
},
"updatePermission": {
"intent": "notification.simple.text"
}
}
}
}
}
When I do the simulation, asks me a permission for a push, but not for the intent I specified.
I'm quiet sure that the problem is the updatePermission, something must be wrong with that:
Is it the field name?
In intent, i put the intent name that i filled in dialogflow, maybe do i have to an use action? Is it in the good format ?
If someone can help me or just give me an example of a clean response for an update permission.
Thanks!
Solution
I just found why, my json wasn't good, the updatePermissionValueSpec must be into data object.
{
"source": "webhook",
"payload": {
"google": {
"expectUserResponse": true,
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"permissions": [
"UPDATE"
],
"updatePermissionValueSpec": {
"intent": "notification_simple_text"
}
}
}
}
}
}
I believe updatePermission should be named updatePermissionValueSpec.
Example response:
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"permissions": [
"UPDATE"
],
"updatePermissionValueSpec": {
"intent": "intent_name"
}
}
}
}
}
Related
I believe I am successfully posting a new post to the endpoint
https://api.linkedin.com/v2/ugcPosts
using (similar to)
{
"author": "urn:li:organization:1234567",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"attributes": [],
"text": "Some share text"
}
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
The response I get is
{"id":"urn:li:share:01234567890123456789"}
But then when I go to the company page, the post is not visible. Note that the IDs are redacted here. Is there another step I have to take?
edit: I went to verify the post with the endpoint https://api.linkedin.com/v2/ugcPosts/[redacted URN]?viewContext=AUTHOR and my post is a success
{
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"inferredLocale": "en_US",
"attributes": [],
"text": "Test article sharing article on LinkedIn API , please ignore"
},
"media": [
{
"media": "urn:li:digitalmediaAsset:XXXXXXXXXXXXXX",
"title": {
"attributes": [],
"text": "image"
},
"thumbnails": [],
"status": "READY"
}
],
"shareFeatures": {
"hashtags": []
},
"shareMediaCategory": "IMAGE"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
},
"created": {
"actor": "urn:li:person:XXXXXXXXXXXXXX",
"time": 1649285262053
},
"author": "urn:li:organization:XXXXXXXXXXXXXX",
"clientApplication": "urn:li:developerApplication:XXXXXXXXXXXXXX",
"versionTag": "0",
"id": "urn:li:share:XXXXXXXXXXXXXX",
"firstPublishedAt": 1649285262053,
"lastModified": {
"actor": "urn:li:csUser:7",
"time": 1649285262122
},
"distribution": {
"externalDistributionChannels": [],
"distributedViaFollowFeed": true,
"feedDistribution": "MAIN_FEED"
},
"contentCertificationRecord": "{\"spamRestriction\":{\"classifications\":[],\"contentQualityClassifications\":[],\"systemName\":\"MACHINE_SYNC\",\"lowQuality\":false,\"contentClassificationTrackingId\":\"073BB82AD64A7608E3F142B6D0362E3D\",\"contentRelevanceClassifications\":[],\"spam\":false},\"originCountryCode\":\"ca\",\"modifiedAt\":1649285262024,\"contentHash\":{\"extractedContentMd5Hash\":\"0725A7E31B109EB4CFB84D2648CE3EC8\",\"lastModifiedAt\":1649285262023}}"
}
What am I missing here?? Why is it now showing on LinkedIn??
edit2 : went ahead and tried to share the post again, now all the posts are gone from the company page when viewed as admin, but showing (except the API posts) as a member.... How broken is this API ??????
I will answer my own post. Uploads using CurlFile DO NOT WORK, you have to use Guzzle... Once the upload & publishing are done, the feed will unbreak itself.. The company page will be broken if the endpoint is still waiting for upload while you post.
$client = new \GuzzleHttp\Client();
$res = $client->request('PUT', $__url, [
'headers' => [
'Authorization' => 'Bearer ' . $__token
],
'body' => fopen($__file, 'r')
]
);
if($res){
$res = json_decode($res->getBody());
}
I am trying to increment my Cloud Firestore using the REST API, however the documentation is unclear as to how this works. Here is my current implementation:-
I am trying to increment the integer value 'c' by 2, so if server value stored is 10 I want it to become 12 with this. Please help.
{
"writes": [
{
"currentDocument": {
"exists": true
}
},
{
"transform": {
"document": "projects/project_name/databases/(default)/documents/collection_name/user_id",
"fieldTransforms": [
{
"increment": {
"c": {
"integerValue": "2"
}
}
}
]
}
}
]
}
Error I keep getting:-
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"\": Root element must be a message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"\": Root element must be a message."
}
]
}
]
}
}
Edit: Here's the error after fixing my payload:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"writes\" at 'document': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document",
"description": "Invalid JSON payload received. Unknown name \"writes\" at 'document': Cannot find field."
}
]
}
]
}
}
As per the FieldTransform documentation, you must set a fieldPath on your JSON representation. Here's the list of possible types for union field transform_type:
{
"fieldPath": string,
// Union field transform_type can be only one of the following:
"setToServerValue": enum (ServerValue),
"increment": {
object (Value)
},
"maximum": {
object (Value)
},
"minimum": {
object (Value)
},
"appendMissingElements": {
object (ArrayValue)
},
"removeAllFromArray": {
object (ArrayValue)
}
// End of list of possible types for union field transform_type.
}
You should remove the fieldPath which is c inside the increment:
"fieldTransforms": [
{
"increment": {
"c": {
"integerValue": "2"
}
}
}
]
and change it to this structure:
"fieldTransforms": [
{
"fieldPath": "<FieldName>",
"increment": {
"integerValue": "2"
}
}
]
And also, just want to note that currentDocument and transform should be both inside the objects of writes. For reference, here's the full JSON representation based on your given JSON representation above:
{
"writes": [
{
"currentDocument": {
"exists": true
},
"transform": {
"document": "projects/project_name/databases/(default)/documents/collection_name/user_id",
"fieldTransforms": [
{
"fieldPath": "c",
"increment": {
"integerValue": "2"
}
}
]
}
}
]
}
Here's the result by using the Postman:
For more information, you may want to check Firebase REST API: Write.
I working on elastic search and I have 1K phone numbers when I pass this phone numbers array to elastic search to search users through phone numbers it gives me exception
Failed to JSON encode /var/app/current/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Serializers/SmartSerializer.php
Below is my Elasticsearch client initializing
$client = ClientBuilder::create()->setHosts([$host])->build();
And my working query in Elasticsearch
{
"_source": [
"id"
],
"query": {
"bool": {
"must": [
{
"term": {
"type": "user"
}
},
{
"bool": {
"should": [
{
"prefix": {
"phone": {
"value": "923047698099"
}
}
},
{
"prefix": {
"phone": {
"value": "92313730320"
}
}
},
.
.
.
]
}
}
],
"must_not": [
{
"has_child": {
"type": "blocked",
"query": {
"term": {
"user_id": "u-2"
}
}
}
},
{
"has_child": {
"type": "block",
"query": {
"term": {
"user_id": "u-2"
}
}
}
},
{
"term": {
"db_id": 2
}
}
]
}
}
}
I don't know that where I doing mistake. Either at client initializing or writing elasticserch query. I searched this issue but not usefull solution found or might be I did't understand clearly. But still I am stucked on this issue that how to solve this problem. Suggest any usefull link or solution.
Thanks
I am using Drupal 8.3.x.
The simple requirnment is like, user need to update his password by entering his old and new password.
By Google I found this link and using it but I am not understand how to send new password?
HTTP request is like this.
Method:
PATCH
HEADER:
Authorization:Bearer <token>
Content-Type:application/hal+json
Body:
{
"_links": {
"type": {
"href": "{domain}/rest/type/user/user"
}
},
"pass": [
{"existing":"testpass"}
]
}
Now how to set new password here?
Analogously to updating mail action
{
"_links": {
"type": {
"href": "{domain}/rest/type/user/user"
}
},
"pass":[{"existing":"testpass"}],
"mail":{
"value":"updatedtestuser#mailserver.com"
}
}
it should be sth like
{
"_links": {
"type": {
"href": "{domain}/rest/type/user/user"
}
},
"pass": [
{"existing":"testpass", "value": "newpass"}
]
}
All,
I have an AJAX request, which makes a JSON request to a server, to get the sync status. The JSON Request and responses are as under: I want to display a JQuery UI progressbar and update the progressbar status, as per the percentage returned in the getStatus JSON response. If the status is "insync", then the progressbar should not appear and a message should be displayed instead. Ex: "Server is in Sync". How can I do this?
//JSON Request to getStatus
{
"header": {
"type": "request"
},
"payload": [
{
"data": null,
"header": {
"action": "load",
}
}
]
}
//JSON Response of getStatus (When status not 100%)
{
"header": {
"type": "response",
"result": 400
},
"payload": [
{
"header": {
"result": 400
},
"data": {
"status": "pending",
"percent": 20
}
}
]
}
//JSON Response of getStatus (When percent is 100%)
{
"header": {
"type": "response",
"result": 400
},
"payload": [
{
"header": {
"result": 400
},
"data": {
"status": "insync"
}
}
]
}
Assuming you want your progress bar/message to be placed in a div named "loadingDiv":
$(document).ready(function() {
var myLoadingDiv = $("#loadingDiv");
myLoadingDiv.progressbar({disabled:true});
$.getJSON("getStatus.php", function(data) {
if (data.payload.data.status == "insync") {
myLoadingDiv.progressbar("disable");
myLoadingDiv.html("Server is in Sync");
}
else if (data.payload.data.status == "pending") {
myLoadingDiv.progressbar("enable");
myLoadingDiv.progressbar("value", data.payload.data.percent);
}
else {
//something else if there are any other status'
}
});
});