Closed digitalfiz closed 7 years ago
This is question for api.ai support, but... What are you name slot? Please, Could you send me screenshot of your intent?
I have a test intent right now with a location parameter: https://i.imgur.com/dNmJWrP.png
When I said slots I mean the parameters
My request looks like this:
const context = {
name: 'location',
parameters: {
'location': process.env.DEVICE_LOCATION
}
};
settings = {
sessionId: 'lololololololol',
contexts: [ context ]
};
const request = app.textRequest(text.trim(), settings);
The call that goes to the fullfillment api has the location in the context but the parameter for location is not filled. See below:
{
"source": "agent",
"resolvedQuery": "input location",
"speech": "",
"action": "input_location",
"actionIncomplete": false,
"parameters": {},
"contexts": [
{
"name": "input_location",
"parameters": {
"location": "Bedroom"
},
"lifespan": 4
}
],
"metadata": {
"intentId": "-------------------------------",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"intentName": "input_location"
},
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"speech": ""
}
]
},
"score": 1
}
I realize I can make the fullfillment api look in both spots (the context and parameters) but I would like to make the location required in api.ai so it can ask questions if it's a device that doesn't have a location like a phone.
I've made example for your case. See screenshot of intent here. I've marked parameters as required. Fill it by context "location" with parameter "location".
So... If you pass the context then parameter will be filled immediately, else platform ask you location with phrase from promts.
'use strict';
var apiai = require("apiai");
var app = apiai("29e11ba32aec42e0b42acc1f9d01dfa7");
var options = {
sessionId: 'session______id',
resetContexts: true,
contexts: [{
name: "location",
lifespan: 1,
parameters: {
location: "main room 1",
}
}]
};
var request = app.textRequest('trigger light', options);
request.on('response', function(response) {
console.log(JSON.stringify(response, null, 4));
});
request.on('error', function(error) {
console.log(error);
});
request.end();
You can comment context definition and platform ask you about you location.
P.S. Don't use "@location" entify for your case. The entity made for geo locations.
"#location.location" - parameter "location" from "location" context if the contexts is present else empty. "@sys.any" - entity for any string parameter.
Ah my problem was I was signing the location parameter to $location. This is what I had to do to get it to work for both specifying a location and assuming one from context: https://i.imgur.com/t8piprJ.png
Also thanks for the help!
Hmm I can't do that. The context is required. I can make another intent though that would handle queries with a location specified in the text.
If you specify location in intent, the context will be required. Just skip it and use like me. Then the context will be optional.
Sure... Or create another intent with/without the contexts.
Have we resolved your issue?
Yes thank you!
You're welcome! No problem!
I am working on a voice assistant that is location aware and I want to be able to fill the location slot with the initial request. Say something like "bot, turn the lights off" which would trigger an intent with a location slot. I tried sending it in context but that doesn't seem to fill the slot?