I'd like to make Alexa to listen for special number - words like for example:
one two three,
one two,
five, six,
eight, nine, ten,
eleven
So I created this intent with the slot-type AMAZON.NUMBER:
Can I make Alexa to just trigger this intent if the input words are on a specific list? ( Just trigger the intent if the input is "one two three" or "five six" and not if the input is e.g. "nine eleven")
How can I capture the words on my node.js server like capturing "one two three" instead of the automatic result "123" = "onehundredtwentythree"?
skill.intent("numeric_input", function(request, response) {
let inputID = request.slot("input").toLowerCase();
response.shouldEndSession(false)
console.log(inputID); // is "123"
})
Any help would be really appreciated.
If you know how many numbers your input could have I would create utterances, such as: {input}, {input}{input}, {input}{input}{input}. Of course this will only work if you know, that number sequences are up to three numbers long.
To change numbers to words, you will have to use some sort of package or write it yourself to convert them, because alexa doesn't have any such functionality.
I have one more suggestion. If you know, that user can only say 1-9 numbers. That is not a lot and you can create custom slot with these values. In this case, alexa will return words to your code and you can block off certain numbers, that you don't want to get, f.e. eleven.
As you did, you have to use AMAZON.Number slot type.
Can I make Alexa to just trigger this intent if the input words are on a specific list?
When you create a custom slot type, a key concept to understand is that this is training data for Alexa’s NLP (natural language processing). The values you provide are NOT a strict enum or array that limit what the user can say. This has two implications
1) words and phrases not in your slot values will be passed to you,
2) your code needs to perform any validation you require if what’s said is unknown.
It's always a good idea to validate the slot values at your backend. If the numbers are something which you don't support, respond back with a proper error message like
"Sorry I can proceed wiht Nine eleven, please give the correct number"
This way you will let your users know that they have to use a different number. If there is number input, any number can come in. So validate and guide.
How can I capture the words on my node.js server like capturing "one
two three" instead of the automatic result "123" =
"onehundredtwentythree"?
If you use AMAZON.Number slot type, the values will come as 123.
"numberSlot": {
"name": "numberSlot",
"value": "123",
"confirmationStatus": "NONE"
}
You can easily validate 123 or convert it to any form as you need.
automatic result "123" = "onehundredtwentythree"?
I really didn't understand this. 123 is not automatically convereted to onehundredtwentythree. If you are pointing to the outspeech, or how Alexa speaks 123, then its a different case. Use <say-as interpret-as="digits">123</say-as> in you output SSML to spell each digit separately.
1.Create custom slot
2. Go to bulk edit of custom slot created and insert numbers in letters. You can get help from this link. Numbers in letters (Filter the numbers you don't want)
3.Create custom intent using the custom slot
Related
I am new to dialogflow. I learned some things the previous month, but I am still searching for how to put a lot of pictures in intent and sending only one to the user, not all of them, and randomly, such as text responses as a kind of entertainment inside the Agent ...
Note :
I linked the client to Facebook Messenger and I want to send the photo there
Can i do this?
Assuming you're using Dialogflow-fulfillment library to respond to webhook requests this should do the trick.
You can store whatever type of response that you want to send in an array...
For example, I'll choose an array of plain text responses
const responses = [
"I didn't get that. Can you say it again?",
'I missed what you said. What was that?',
'Sorry, could you say that again?',
'Sorry, can you say that again?',
'Can you say that again?',
"Sorry, I didn't get that. Can you rephrase?",
'Sorry, what was that?',
'One more time?',
'What was that?',
'Say that one more time?',
"I didn't get that. Can you repeat?",
'I missed that, say that again?'
]
Given the array you can generate a random number between 0 (most programming languages index from 0) and the length of the array.
const index = Math.floor((Math.random() * responses.length) + 1)
In the above case, index is assigned to any number between 0 and 11. You can then pass this index into the array to randomly choose 1 value.
agent.add(responses[index])
You can take this concept and apply it to any response type you want.
Hope this does the trick for you!
I'm now stuck on the problem of getting user input (what user says) in my index.js. For example, the user says: please tell me if {animals} can live between temperature {x} to {y}. I want to get exact value (in string) for what animals, x and y so that I can check if it is possible in my own server. I am wondering how to do that since the entities need to map to some exact key values if I annotate these three parameters to some entities category.
The methods for ApiAiApp is very limited: https://developers.google.com/actions/reference/nodejs/ApiAiApp
And from my perspective, none of the listed methods work in this case.
Please help!
Generally API.AI entities are for some set of known values, rather than listening for any value and validating in the webhook. First, I'd identify the kinds of entities you expect to validate against. For the temperatures (x and y), I'd use API.AI's system entities. Calling getArgument() for those parameters (as explained in the previous answer) should return the exact number value.
For the animals, I'd use API.AI's developer entities. You can upload them in the Entity console using JSON or CSV. You can enable API.AI's automated expansion to allow the user to speak animals which you don't support, and then getArgument() in webhook the webhook will return the new value recognized by API.AI. You can use this to validate and respond with an appropriate message. For each animal, you can also specify synonymous names and when any of these are spoken, and getArgument() will return the canonical entity value for that animal.
Extra tip, if you expect the user might speak more than one animal, make sure to check the Is List box in the parameter section of the API.AI intent.
If "animals", "x", and "y" are defined as parameters in your Intent in API.AI, then you can use the getArgument() method defined in ApiAiApp.
So the following should work:
function tempCheck( app ){
var animals = app.getArgument('animals');
var x = app.getArgument('x');
var y = app.getArgument('y');
// Check the range and then use something like app.tell() to give a response.
}
I am trying to track all tweets by given hashtag or keyword. The problem is I can stream the tweets when I use a simple keyword like 'animal' but when I change it to say 'animal4666' then it doesn't work. No reply is received. I am using the code below.
twit.stream('statuses/filter', { track: 'animal4666' }, function(stream) {
stream.on('data', function(data) {
console.log(util.inspect(data));
});
});
I have made two tweets from different account like following:
'#animal4666 a'
'#animal4666 trying to find out what is going on?'
Above tweets are successfully retrieved using search API but because of the rate limitations on search API I need to use stream API so that i can check for new tweets every two seconds with node.js
The addon I am using of node.js: https://github.com/jdub/node-twitter
Can someone please help?
If you look the code of the library you are using, it seems that there is nothing potentially wrong
it only has a workaround when you pass an array in the track param, but is not the case
// Workaround for node-oauth vs. twitter commas-in-params bug
if ( params && params.track && Array.isArray(params.track) ) {
params.track = params.track.join(',')
}
So looking in to the official api docs for track method, I see two caveats that may are relevant.
Each phrase must be between 1 and 60 bytes, inclusive.
I think yours are shorter but is something to take in mind
And what I think is your real problem:
Exact matching of phrases (equivalent to quoted phrases in most search
engines) is not supported.
Punctuation and special characters will be considered part of the term
they are adjacent to. In this sense, "hello." is a different track
term than "hello". However, matches will ignore punctuation present in
the Tweet. So "hello" will match both "hello world" and "my brother
says hello." Note that punctuation is not considered to be part of a
#hashtag or #mention, so a track term containing punctuation will not match either #hashtags or #mentions.
You can check online your tweet text to see if it match here
In groovy, I want to search text (which is typically an xml structure) and find an occurrence of the ignore list.
For example:
My different search data requests are (reduced for clarity, but most are large):
<CustomerRQ field='a'></CustomerRQ>
<AddressRQ field='a'></AddressRQ>
My ignore list is:
CustomerRQ
CustomerRS
Based on the above two incoming requests of "customer" and "address", I want to ignore "Customer" since it's in my ignore list, but I want to identify "address" as a hit.
The overall intent is to use this for logging. I want to not log some incoming requests based on my "ignore" list, but all others will be logged.
Here's some pseudo code that may be on the right track but not really.
def list = ["CustomerRQ", "CustomerRS"]
println(list.contains("<CustomerRQ field='a'>"))
I'm not sure, but I think a closure will work in this case, but learning the groovy ropes here. Maybe a regexp will work as well. But the importance is to search in the incoming string (indexOf, exists...) across all of my exclusions list.
A quick solution:
shouldIgnore = list.inject(false) { bool, val -> bool || line.contains(val) }
Whether or not this is the best idea depends on information we don't have; it may be better to do something more-XMLy rather than checking against a string.
I am trying to validate one block of json data that I receive from server
json consists of information about bunch of orders. An each order includes cost of each part, taxes and total. And it is kind of strict requirement each order contains exactly 4 parts. And each order has three kind of taxes and a total.
I have a step which looks like this
And "standardorder" includes parts "1..4", taxes "1..3" and total
and step implementation is like following. Here #jsonhelper.json is shared state (json for one order) passed from previous step.
And /^"([^"]*)" includes parts "([^"]*)", taxes "([^"]*)" and total$/ do |arg1, arg2, arg3|
json = #jsonhelper.json
validkeys = ["total"]
parts = arg2.split('..').map{|d| Integer(d)}
(parts[0]..parts[1]).each do |i|
validkeys.push "p#{i}"
end
taxes = arg3.split('..').map{|d| Integer(d)}
(taxes[0]..taxes[1]).each do |i|
validkeys.push "t#{i}"
end
validkeys.each do |key|
json[arg1].keys.include?(key).should be_true
end
end
Now this script works fine except that if any one key is missing it doesn't state which one is missing. Either it passes or fails as assertions are iterated for each key.
I would like to know if there is any possibility of sending keys which are found ok to result stream. Thus my intention is to know to which keys are ok and which failed and which one skipped. As such order of keys is not expected in json.
Thanks in advance.
It's probably best to split the step definitions first:
And "standardorder" should be received
And the order should include parts 1 to 4
And the order should include taxes 1 to 3
And the order should include the total
Then you can re-use the steps elsewhere.
The 'order' check easy to implement as you're just checking one element.
For the other two, you are really just checking the presence of items in an array, e.g.:
actual_values.should == expected_values
If that fails, RSpec will give you a report showing how the arrays differ.