Change prompt server sided - actions-on-google

I am starting to work myself into aog. I use the SDK and the WebSimulator only right now. What I am trying to achieve is to change the prompt I set before, e.g. because I have new information available. I tried the following which fails:
let inputPrompt = assistant.buildInputPrompt(true, '<speak>1+1=3 Agree?</speak>',['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
assistant.ask(inputPrompt);
let inputPrompt2 = assistant.buildInputPrompt(true, '<speak>Sorry! 1+1=2 Agree?</speak>',['I didn\'t hear a number', 'If you\'re still there, what\'s the number?', 'What is the number?']);
assistant.ask(inputPrompt2);
Only the first prompt is presented and then - only after the user responded - the second one.
Is it possible at all to change the prompt server sided? How can it be done? Or is there maybe a workaround?

The assistant.ask() method will send the prompt to the user and then wait for a response.
If you're trying to send something to the user, and then send something else before they have replied, you're not able to do this currently using Actions. That would be more like a notification or an asynchronous operation.

Related

Powershell Selenium: Unable to Locate Element on Amazon

I'm trying to create a Selenium script in Powershell that automatically buys something that I tell it to. I've gotten it past finding the item, and clicking the Buy Now button, but then this window pops up and I've tried what seems like 3000 different ways of failing to click the Place your order button. Web code to the right. Appears to be the "turbo-checkout-pyo-button", but finding it by ID, XPath, CSSselector, etc have all failed for me. It's not a wait issue. I've even thrown in an explicit (and overly long) 5 second delay to be sure this field is present and "should" be clickable. Any ideas?
I've tried all of these. They're all followed by $placeYourOrderBtn.click() (and have all failed):
$placeYourOrderBtn = $ChromeDriver.FindElementByXpath("//*[#id='turbo-checkout-pyo-button']")
$placeYourOrderBtn = $ChromeDriver.FindElementByXPath("//*[#id='turbo-checkout-place-order-button']")
$placeYourOrderBtn = $ChromeDriver.FindElementByXPath("//span[text() = Place your order]")
$placeYourOrderBtn = $ChromeDriver.FindElementById("turbo-checkout-place-order-button-announce")
$placeYourOrderBtn = $ChromeDriver.FindElementById("turbo-checkout-pyo-button")
$placeYourOrderBtn = $ChromeDriver.FindElementByCssSelector("#turbo-checkout-pyo-button")
I did this for a windows that sends email. You have to click the button to open the new window, then use "SwitchTo()" to change to the new window.
[void]$Webdriver.SwitchTo().Window($WebDriver.WindowHandles[1])
You may have to read the window handles attribute and query each one to determine which one you need to open.

Alexa Confirmation of Number

I ask the user for a number for a slot and then want to confirm the number. The numbers are seven digits(e.g., 5433975).
Alexa confirms by saying the number as a value rather than saying each digit.
I have tried '{acblNumber} right' for the confirmation and it does not work.
I hope someone has a solution.
You must send speech output as SSML type:
speechOutput = "<say-as interpret-as='digits'>5433975</say-as>"

So I've mad a hug command but I would like it so it wouldnt # the person being hugged

So I've made a hug command that goes like <3hugs #thisperson (<3 is my prefix) and it will come out as #thisotherperson hugs #thisperson. And I would like it not to # the person getting hugged. because I want it so that if the bot gets hugged it responds. However because of the # it goes on a loop (which I fixed) but it says the response twice. I hope that made sense. Also, I am very new to coding and making a bot :p
I've tried using different terms, but ultimately i dont know what exactly i should use and i cant find it anywhere.
case 'hug':
if(!args[1]){
message.reply('who is this hug for?')
}else{
message.channel.send(`${message.author} huggies you, ${member} !!!!!`);
}
break;
bot.on('message', msg=> {
if (msg.isMentioned(bot.user)) {
msg.channel.sendMessage('AWWWWWWW!! THANKIES!! Love you too!!');
}
}); //... this is the code i use for the bots response
So I expected that if perhaps the bot gets chosen to be hugged in the <3randhug then it would have its own response. and it works fine, because the bot only gets # once. However, when a person choses to hug the bot it gets # twice.
Like
Sofira: <3 hug #cloudbot
Bot: Awwwwwww
Bot:#Sofira huggies you #cloudbot
Bot: awwwwwww
Alright, so you want the second "awwww" to not happen, right? Is there a way you can compare two different message authors? Like making the "awwww" block conditional. As an example, making it so that instead of just replying with "awwww" to every message that mentions it, making it only reply with awww to a member other than itself mentioning it. Also, without a conditional statement like that, even just a message like "#CloudBot" will still cause the whole "aww" response.

google action conversation exit: not waiting for user response

I am trying to seek user feedback at the end of a google action session using actions sdk.
As per the Actions documentation (https://developers.google.com/actions/assistant/conversation-exits), I have set the cancel intent
"conversations" : {
...
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
},
...
and in my functions code I am calling a SimpleResponse as below:
app.intent('actions.intent.CANCEL', (conv, input) => {
conv.close(new SimpleResponse({
speech: 'Kindly rate between 1 and 5,
text: 'Rate between 1 and 5'
}));
});
When the user says goodbye, the above code gets called. The speech is heard and text displayed but the conversation immediately exits with an earcon.
The documentation mentions that the system will wait for 2 seconds before exiting but it seems to do so immediately. Is there a way to get this working? Thanks
It's not quite clear to me what you'd like to achieve. First of all, as long as you're using conv.close() method, you are ending the conversation. If you want to keep the mic open, you need to use conv.ask() method. But I'm not sure id you can use conv.ask() with actions.intent.CANCEL, because that event is there to get the user out, not to keep the conversation going. But I'm not %100 sure, you need to try it.
If what you're trying to achieve is something like this:
User: cancel
System: How would you rate our interaction?
User: Good.
earcon
Then, in my humble opinion, you probably shouldn't (and as I said you probably can't) do it. The docs clearly state that the purpose for custom exit behavior is:
to cleanup your fulfillment logic and respond to the user one last time.
Also, the docs doesn't say the system will wait for the user response for 2 second. It says the execution of the request (the time out for your fulfillment) is 2 seconds. Plus; if a user is canceling mid-conversation, chances are that the interaction was unsuccessful anyway. I'd rather create feedback dialog turns that are connected to the fallback intents and happy path(s).
Still, try to use conv.ask() instead and let me know if that works. (And please let me know by commenting.) Either case, though, I'd consider getting the feedback some other way.

Notification window with buttons in Linux

I have a Perl script which listens to a port and filters messages, and, based on them, proposes to take action or ignore event.
I'd like to make it show a notification window (not a dialogue window) with buttons 'take action' and 'ignore', which would go after a certain timeout.
So far I have something like this:
my #react = ("somecommand", "someoptions); # based on what regex a message matched
my $cmd = "xmessage";
my $cmd_args = "-print -timeout 7 -buttons React,Dismiss $message"; # raw message from port
open XMSG, "$cmd $cmd_args |";
while (<XMSG>) {
if ($_ eq "React\n") {
do something...
}
}
But it would handle only one notification at once, and the next message would not appear until the previous one is dismissed, reacted to or timed out, so it's quite a bad decision. I cannot do anything until I get return code from xmessage, and I can't get xmessage run a command. Well I probably can if I introduce event IDs and listen to a socket where xmessage prints, but it would make things too complicated, I guess.
So I wonder is there a library or an utility for Linux to draw notify-like windows with buttons which would each trigger a command?
I'm sorry I didn't see this one when it first was posted. There are several gui toolkits which could do something along these lines. Prima is a toolkit built especially for Perl and has no external library dependencies.
For when you just need a popup dialog, there is the Ask module which delegates the task of popping up windows to any available library.
In case anyone's interested, I've ended up writing a small Tcl/Tk program for that, the full code (all 48 lines) can be found here: http://cloudcabin.org/read/twobutton_notify, and you can ignore the text in Russian around it.