This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sphero = require("sphero"), | |
sprk = sphero("EA:FE:34:55:2A:E0"); // change BLE address accordingly | |
sprk.connect(function() { | |
// roll Sphero in a random direction, changing direction every second | |
setInterval(function() { | |
var direction = Math.floor(Math.random() * 360); | |
sprk.roll(150, direction); | |
}, 1000); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const {dialogflow} = require('actions-on-google'); | |
const admin = require('firebase-admin'); | |
const functions = require('firebase-functions'); | |
const app = dialogflow({debug: true}); | |
admin.initializeApp(functions.config().firebase); | |
const db = admin.firestore(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2018, Google, Inc. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('setup_price_update', (conv, {cryptocurrency}) => { | |
const intent = conv.arguments.get('UPDATE_INTENT'); | |
conv.ask(new RegisterUpdate({ | |
intent: intent, | |
arguments: [ | |
{ | |
name: 'cryptocurrency', | |
textValue: cryptocurrency, | |
}, | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('finish_price_update_setup', | |
(conv, params, registered) => { | |
if (registered && registered.status === 'OK') { | |
conv.close(`Ok, I'll start giving you daily updates.`); | |
} else { | |
conv.close(`Ok, I won't give you daily updates.`); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('setup_price_update', (conv) => { | |
const intent = conv.arguments.get('UPDATE_INTENT'); | |
conv.ask(new RegisterUpdate({ | |
intent: intent, | |
})); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conv.ask('The price of one ' + base + " is " + | |
Number(price).toFixed(2) + " " + target); | |
// Suggestion max length is 25 characters | |
conv.ask(new Suggestions(['Warn me a 10% price drop', | |
'Send me Daily Updates'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('finish_exchange_rate_setup_push', (conv, params) => { | |
if (conv.arguments.get('PERMISSION')) { | |
//const userID = conv.user.id; | |
const userID = conv.arguments.get('UPDATES_USER_ID'); | |
// code to save intent and userID in your db | |
conv.close(`Ok, I'll start alerting you.`); | |
} else { | |
conv.close(`Ok, I won't alert you.`); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('exchange_rate_setup_push', (conv) => { | |
conv.ask(new UpdatePermission({intent: 'cryptocurrency_price'})); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conv.ask('The price of one ' + base + " is " + | |
Number(price).toFixed(2) + " " + target); | |
// Suggestion max length is 25 characters | |
conv.ask(new Suggestions('Warn me a 10% price drop')); |
NewerOlder