= assistant.getArgument('speaker'); var speaker = findSpeakerByName(speakerName); if (speaker != null) { var event = findEventBySpeaker(speaker); if (event != null) { assistant.tell(speakerName + ' will be talking about ' + event.name + ' at ' + toDayAndTime(event.start_time); } } assistant.tell('No presentation by ' + speakerName + ' could be found...'); }
topic and ask which one the use wants to hear about function findEventByTopic(assistant) { const topic = assistant.getArgument('topic'); var matchingEvents = findEventsByTopic(topic); // Returns array of events var response = 'I found the following events; ' for (var event in matchingEvents) { response += event.name + ' at ' + toDayAndTime(event.start_time) + '. '; } response += 'Which one do you want to hear more about?' // Input prompts when no reply is given const noInputPrompts = ['Which event do you want to hear more about?', 'Say the name of the event.', 'Ok, bye for now!']; assistant.ask(response, noInputPrompts); }
var event = findEventByName(eventName); var speakers = findSpeakersForEvent(event); var response = eventName + ' starts at ' + toDayAndTime(event.start_time) + ' and is presented by ' + speakers.join(' and ') + '. ' + 'The description reads; ' + event.description; assistant.tell(response); }
// Read a message to the user, ends conversation. assistant.tell(message); // Get an argument from the interpreted voice input. var arg1 = assistant.getArgument("arg1"); // Read a message asking for further input assistant.ask(question, noInputs); // Get the raw input var rawInput = assistant.getRawInput(); // Map function to intent const actionMap = new Map(); actionMap.set('lookup-speaker-event', lookupSpeakerEvent); actionMap.set('find-events-by-topic', lookupEventsByTopic); actionMap.set('give-event-details', giveEventDetails); assistant.handleRequest(actionMap)
them credit • Optimize for relevance • Delight the ear without distracting the mind • Engage beginners and attract experts • Take turns • Don't read minds https://developers.google.com/actions/design/ principles