This file contains hidden or 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
"search": [{ | |
"name": ".*Conversation.data", | |
"subtitle": "Session data" | |
}, { | |
"name": "conversation/response.*", | |
"subtitle": "Rich response" | |
}, { | |
"name": "conversation.User.storage", | |
"subtitle": "Persistent storage" | |
}] |
This file contains hidden or 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
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') | |
}); |
This file contains hidden or 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
const getEmail = async (headers) => { | |
const accessToken = headers.authorization.substr(7); | |
const {email} = await auth0.getProfile(accessToken); | |
return email; | |
} |
This file contains hidden or 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
// 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(); |
This file contains hidden or 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
@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."; |
This file contains hidden or 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
<?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> |
This file contains hidden or 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
interface TabletopAudioResponse { | |
tracks: TabletopAudioTrack[] | |
} | |
interface TabletopAudioSession { | |
json: TabletopAudioResponse, | |
currentTrack: TabletopAudioTrack | |
} | |
interface TabletopAudioTrack { |
This file contains hidden or 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
async function cacheResults(conv: Conv) { | |
const response = await fetch(tabletopAudioUrl) | |
const json: TabletopAudioResponse = await response.json() | |
conv.data.json = json | |
} |
This file contains hidden or 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.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 | |
} |
This file contains hidden or 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.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 | |
} |