Closed Aashish-1008 closed 7 years ago
Cann't we do this using events which attached to intent and then we will set the event data to params.
Also is there any way to set some global context . From where i can access data in all my intents like access_token, otherwise everytime i need to set in context and give some life span.
I could implement a method which sets a "permanent" context:
ApiAi.setPermanentContexts([{name: "sample", parameters: {access_token: "your access token"}])
Then I would set this context on every request with lifespan 1.
Would this help you?
perfect thanks !! One more thing const contexts = [{ name: "config", lifespan: 1, parameters: { access_token: "your access token" } }];
Using set contexts i able to trigger my corresponding intent. But i don't know how to get those sent parameters to my node web hook.
when this intent triggers the post request API.ai is making sends empty contexts object to my web hook.
This is how i am setting action parameter in API.ai
Ok.. I will implement setPermanentContexts
next weekend.
I've not done something with webhooks so far but the whole contexts should accessible via the request object req
of the official example:
https://api.ai/docs/getting-started/basic-fulfillment-conversation
Thanks !!
Hey, i guess sending events is not present in this module. Can you add support for that also. It will be highly appreciated. Thanks.
Yepp I'm planning to add events, but I stuck on one issue a little bit. It will take some more time for events and it is not on the top position on my todo list. If you need events urgent I recommend following workaround:
This is actually the same as request an event.
I found a another way to send events. As api.ai is totally exposed via api endpoints .So we can also send events by making a api post request to api.ai .
This is code: var data = { "event": { "name": "YOUR_EVENT_NAME", "data": { "token": "aashish.." } }, "timezone": 'America/New_York', 'lang': "en", "sessionId": currentSessionId }
fetch("https://api.api.ai/api/query?v=20150910", {
method: "POST",
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer DEVELOPER_ACCESS_TOKEN',
'charset': "utf-8"
},
body: JSON.stringify(data)
})
.then(function(response) {
var json = response.json().then(function(res){
console.log('---rrr--',res)
})
})
.then(function(data) {
console.log(data)
});
}, error=>console.log(error))
Guys does this support latest version of react-native i am getting an error ld: library not found for -lRNSpeechToTextIos clang: error: linker command failed with exit code 1 (use -v to see invocation)
@Aashish-1008 Thanks for your fetch-method. I implemented it in ApiAi. With version v1.4.0 your have your permanentContext and the ability to requestEvents!
@Arafath-misree I will look into this problem. This is also total out of context of this issue, so I will put your description to a new one and close this one.
You can try using the context: