How do you request device location using webhook, and actions on google v2.
Previously, I used permission_request field, but that is now deprecated, and not sure where it fits into the response object at.
json response
{
speech: "",
displayText: "",
data: {
google: {
expectUserResponse: true,
noInputPrompts: [
{
textToSpeech: "Hello McFly!"
},
{
textToSpeech: "Good talk, Russ"
},
{
textToSpeech: "Alright, I'm just gonna go over here and hang out. Let me know if there is anything else I can do for you."
}
],
richResponse: {
items: [
{
simpleResponse: {
textToSpeech: "Testing",
ssml: "<speak >Testing</speak>",
displayText: "Testing"
},
basicCard: null
}
],
suggestions: [ ],
linkOutSuggestion: {
destinationName: null,
url: null
}
},
systemIntent: null,
possibleIntents: [
{
intent: "actions.intent.PERMISSION",
inputValueData: {
#type: "type.googleapis.com/google.actions.v2.PermissionValueSpec",
optContext: "To provide weather information for you.",
permissions: [
"DEVICE_COARSE_LOCATION"
]
}
}
]
}
},
contextOut: [ ],
source: "Abbi"
}
so i needed to add the permission request as a system intent, not expected intent, or possible intent.
the below json works now
{
speech: "",
displayText: "",
data: {
google: {
expectUserResponse: true,
noInputPrompts: [
{
textToSpeech: "Hello McFly!"
},
{
textToSpeech: "Good talk, Russ"
},
{
textToSpeech: "Alright, I'm just gonna go over here and hang out. Let me know if there is anything else I can do for you."
}
],
richResponse: {
items: [
{
simpleResponse: {
textToSpeech: "",
ssml: "<speak ></speak>",
displayText: ""
},
basicCard: null
}
],
suggestions: [ ],
linkOutSuggestion: {
destinationName: null,
url: null
}
},
systemIntent: {
intent: "actions.intent.PERMISSION",
data: {
#type: "type.googleapis.com/google.actions.v2.PermissionValueSpec",
optContext: "To provide an accurate experience, ",
permissions: [
"DEVICE_PRECISE_LOCATION"
],
carouselSelect: null
}
}
}
},
contextOut: [ ],
source: "Abbi"
}
Related
I have an object with the following model:
export const Address = mongoose.model('Address',
{
id: mongoose.SchemaTypes.ObjectId,
customer_id: String,
addresses: [{
address_type: String,
address_info: String,
}]
});
An example dataset is like this:
{
"data": {
"address": [
{
"customer_id": "12345123",
"addresses": [
{
"address_type": ANDROID,
"address_info": "dfjghjsdgf"
},
{
"address_type": IOS,
"address_info": "dwrw45345f"
}
]
},
{
"customer_id": "12345124",
"addresses": [
{
"address_type": SMS,
"address_info": "dfjghj231dgf"
},
{
"address_type": IOS,
"address_info": "ww242344234"
}
]
}
]
}
}
It's clear that the addresses field of the Address model is a list, within which each object has two fields : address_type, and address_info.
I wonder how to update an address_info with filters in customer_id and address_type? For example, if I would like to update the ANDROID address of customer_id = 12345123 to abcdefg, it's expected to see the database being updated into :
{
"data": {
"address": [
{
"customer_id": "12345123",
"addresses": [
{
"address_type": ANDROID,
"address_info": "abcdefg"
},
{
"address_type": IOS,
"address_info": "dwrw45345f"
}
]
},
{
"customer_id": "12345124",
"addresses": [
{
"address_type": SMS,
"address_info": "dfjghj231dgf"
},
{
"address_type": IOS,
"address_info": "ww242344234"
}
]
}
]
}
}
Reference: Mongoose :Find and filter nested array
This problem talked about findOne, but I'm more interested in update.
you can try like this
await Address.update(
{ customer_id: "12345123", "addresses.address_type": "ANDROID" },
{$set : { "addresses.$.address_info" : "abcdefg" }}
)
playground
I have the following structure of a document in a collection:
A Factory has many departments, which has many areas.
factoryName: "",
departments: [
{
departmentName: ""
areas: [
{
areaName: ""
}
]
}
]
When querying a document via the "areaName", I only want to get the area + respective parent department + respective parent factory.
As an example, please briefly see the below 2 documents.
db.factories.insertMany([{
factoryName: "San Francisco",
departments: [
{
departmentName: "Administration",
areas: [
{
areaName: "Phone Guys"
},
{
areaName: "Email Guys"
}
]
},
{
departmentName: "Development",
areas: [
{
areaName: "Dev Ops"
},
{
areaName: "Programming"
},
{
areaName: "Architecture"
}
]
}
]
},{
factoryName: "Chicago",
departments: [
{
departmentName: "Administration",
areas: [
{
areaName: "Phone Guys"
},
{
areaName: "Email Guys"
}
]
},
{
departmentName: "Logistics",
areas: [
{
areaName: "Delivery"
},
{
areaName: "Human Resources"
}
]
}
]
}])
I wish to query by areaName = "Architecture" and receive back the following:
factoryName: "San Francisco",
departments: [
{
departmentName: "Development"
areas: [
{
areaName: "Architecture"
}
]
}
]
Since usual query combinations via .find() with projection failed (so far), I've tried myself in aggregation.
In order to achieve the wished result, I've tried many things but failing when it comes down to filtering the areas. Filtering the departments' work.
Using MongoDB Compass Visual Aggregation feature, the most logical to me seemed:
db.factories.aggregate([
{
'$match': {
'departments.areas.areaName': 'Architecture'
}
}, {
'$addFields': {
'departments': {
'$filter': {
'input': '$departments',
'as': 'department',
'cond': {
'$and': [
{
'$eq': [
'$$department.departmentName', 'Development'
]
}, {
'$filter': {
'input': '$$department.areas',
'as': 'area',
'cond': {
'$eq': [
'$$area.areaName', 'Architecture'
]
}
}
}
]
}
}
}
}
}
])
It seems a $filter, inside a $filter does not work or I'm missing something here since all 3 areas for the "Development" department are being returned instead of only "Architecture" whereas the "Development" department is being filtered correctly.
How can I achieve this? What am I missing?
Any help is much appreciated.
Many thanks!
You need $filter and $map since you have nested arrays:
db.collection.aggregate([
{
"$match": {
"departments.areas.areaName": "Architecture"
}
},
{
$addFields: {
departments: {
$map: {
input: {
$filter: {
input: "$departments",
cond: {
$in: [ "Architecture", "$$this.areas.areaName" ]
}
}
},
in: {
departmentName: "$$this.departmentName",
areas: { $filter: { input: "$$this.areas", as: "d", cond: { $eq: [ "$$d.areaName", "Architecture" ] } } }
}
}
}
}
}
])
Mongo Playground
i try to send custom payload in Dialogflow from fulfillment(nodejs)
My motive is send link and its text as response to web page.
my sample code for reference:
const response = {
messages: [
{
payload: {
messages: [
{
speech: 'here are some quick links for your convenience.',
linkmessage: [{
message: 'google',
link: 'www.google.com'
}, {
message: 'yahoo',
link: 'www.yahoo.co.in'
}],
button: [{
buttonname: 'more page'
}]
}
]
}
}
]
};
agent.add(new Payload(agent.UNSPECIFIED, response, { rawPayload: true, sendAsMessage: true}));
Here i get the response as:
{
"fulfillment": {
"speech": "",
"messages": [
{
"lang": "en",
"type": 0,
"speech": ""
}
],
"data": {
"null": {
"messages": [
{
"payload": {
"messages": [
{
"speech": "here are some quick links for your convenience.",
"linkmessage": [{
"message": "google",
"link": "www.google.com"
}, {
"message": "yahoo",
"link": "www.yahoo.co.in"
}],
"button": [{
"buttonname": "more page"
}]
}
]
}
}
]
}
}
}
Here you can see in response i am getting "null" object is appended inside the data object in the response.
can any one help me out to remove that null object from dialogflow response, and any other option for sending custom payload from fulfillment nodejs.
function update() {
const response = {
messages: [
{
payload: {
messages: [
{
speech: 'here are some quick links for your convenience.',
linkmessage: [{
message: 'google',
link: 'www.google.com'
}, {
message: 'yahoo',
link: 'www.yahoo.co.in'
}],
button: [{
buttonname: 'more page'
}]
}
]
}
}
]
};
agent.add(new Payload(agent.UNSPECIFIED, response, { rawPayload: true, sendAsMessage: true}));
}
In this function need to add parameter as agent so that you can get non 'null' object
Reference code need to be updated.
function update(agent) {
const response = {
messages: [
{
payload: {
messages: [
{
speech: 'here are some quick links for your convenience.',
linkmessage: [{
message: 'google',
link: 'www.google.com'
}, {
message: 'yahoo',
link: 'www.yahoo.co.in'
}],
button: [{
buttonname: 'more page'
}]
}
]
}
}
]
};
agent.add(new Payload(agent.UNSPECIFIED, response, { rawPayload: true, sendAsMessage: true}));
}
I am searching for objects in Elasticsearch 6.3.
I have 3 objects:
{
identifier: 01,
lineCodes: [],
},
{
identifier: 02,
lineCodes: [
{
link: "brussels",
name: "br"
},
{
link: "antwerp",
name: "an"
},
],
},
{
identifier: 03,
lineCodes: [
{
link: "ghent",
name: "gh"
},
],
}
My lineCodes schema is:
{
"lineCodes": {
"properties": {
"__typename": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"link": {
"type": "keyword"
},
"name": {
"type": "keyword"
}
}
}
}
Can you help me with Query DSL's that find all objects with:
Brussels in lineCodes.link or empty lineCodes
All empty lineCodes
Ghent in lineCodes.link or empty lineCodes
query 1 should result in object 01 and 02
query 2 should result in object 01
query 3 should result in object 01 and 03
I tried this query, but it gives me not the empty LineCodes objects
let query = {
size: 1000,
index: 'catalog',
body: {
query: {
bool: {
must: [
{
bool: {
should: [
{ term: { 'lineCodes.link': lineCode } },
{ terms: { 'lineCodes': [] } },
],
},
}
],
}
}
}
};
You can use the exists query ( doc here ) and negate it with a must_not clause in a bool query
Could you try :
{
size: 1000,
index: 'catalog',
body: {
query: {
bool: {
must: [
{
bool: {
should: [
{ term: { 'lineCodes.link': lineCode } },
{
bool: {
must_not: {
exists: {
field: 'lineCodes'
}
}
}
}
],
},
}
],
}
}
}
}
NB: As you use a term query for linecode.link watch out for case and accents!
Hope it helps !
I am using the Navigation.mergeOptions() function to try to update the badge count of the third tab (tabindex = 2), however, the badge count is not updating. Here's what my original layout object looks like for setRoot:
{
root: {
bottomTabs: {
children: [
{
stack: {
children: [
{
component: {
name: 'navigation.main.Dispensaries',
},
}
],
options: {
topBar,
bottomTab: NavStyles.tab('Dispensaries', dispensariesTabIcon),
}
}
},
{
stack: {
children: [
{
component: {
name: 'navigation.main.Orders',
},
}
],
options: {
bottomTab: NavStyles.tab('My BudBuddy', myBudbuddyTabIcon),
topBar,
}
}
},
{
stack: {
children: [
{
component: {
name: 'navigation.main.Checkout',
},
}
],
options: {
bottomTab: NavStyles.tab('Bag', bagTabIcon, badge),
topBar,
}
}
},
], options: {
//topBar,
bottomTabs: {
currentTabIndex: 0,
},
},
},
}
Then, in one of my components, I did this, but it causes no effect on the badge count:
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
children: [
{}, {},
{
stack: {
options: {
bottomTab: {
badge: '31',
},
},
},
},
],
},
});
I'm quite sure that's wrong, and I even tried replicating the original layout object in the first code block above, except with a different badge count, and it doesn't do anything. Any ideas? Thank you!
Updating options for a specific tab
Hope this helps.