Skip to content

Instantly share code, notes, and snippets.

View Fleker's full-sized avatar
💻
doing good things

Nick Fleker

💻
doing good things
View GitHub Profile
"search": [{
"name": ".*Conversation.data",
"subtitle": "Session data"
}, {
"name": "conversation/response.*",
"subtitle": "Rich response"
}, {
"name": "conversation.User.storage",
"subtitle": "Persistent storage"
}]
@Fleker
Fleker / index.js
Created April 30, 2019 00:34
Setup Auth0 & AoG
const {AuthenticationClient} = require('auth0');
const auth0 = new AuthenticationClient({
'clientId': 'clientIdentifier',
'domain': '<auth0-tenant-id>.auth0.com'
});
const smarthome = require('actions-on-google');
const app = smarthome({
jwt: require('./service-account-key.json')
});
@Fleker
Fleker / getEmail.js
Created April 30, 2019 00:35
Obtain email address from Auth0
const getEmail = async (headers) => {
const accessToken = headers.authorization.substr(7);
const {email} = await auth0.getProfile(accessToken);
return email;
}
@Fleker
Fleker / index.js
Created April 30, 2019 00:35
Handle SYNC intent with user credentials
// Connect to Cloud Firestore
const admin = require('firebase-admin');
admin.initializeApp();
const db = admin.firestore();
db.settings({timestampsInSnapshots: true});
app.onSync(async (body, headers) => {
const userEmail = await getEmail(headers);
const userDoc = await db.collection('users').doc(userEmail).get();
@Fleker
Fleker / ActionsApplication.java
Created May 21, 2019 13:41
Springboot implementation for Action
@SpringBootApplication
public class ActionsApplication {
private static final Logger LOG = LoggerFactory.getLogger(SillyNameMakerApp.class);
private final App actionsApp = new SillyNameMakerApp();
@RestController
class ActionsController {
@GetMapping("/")
String serveAck() {
return "App is listening but requires valid POST request to respond with Action response.";
@Fleker
Fleker / pom.xml
Created May 21, 2019 13:42
Dependencies needed to import Springboot
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
interface TabletopAudioResponse {
tracks: TabletopAudioTrack[]
}
interface TabletopAudioSession {
json: TabletopAudioResponse,
currentTrack: TabletopAudioTrack
}
interface TabletopAudioTrack {
async function cacheResults(conv: Conv) {
const response = await fetch(tabletopAudioUrl)
const json: TabletopAudioResponse = await response.json()
conv.data.json = json
}
app.middleware(async (conv: Conv) => {
await cacheResults(conv)
})
async function cacheResults(conv: Conv) {
if (!conv.data.json) {
const response = await fetch(tabletopAudioUrl)
const json: TabletopAudioResponse = await response.json()
conv.data.json = json
}
app.middleware(async (conv: Conv) => {
await cacheResults(conv)
})
async function cacheResults(conv: Conv) {
if (!conv.data.json) {
const response = await fetch(tabletopAudioUrl)
const json: TabletopAudioResponse = await response.json()
conv.data.json = json
}