Skip to content

Instantly share code, notes, and snippets.

@Fleker
Created December 20, 2019 23:18
Show Gist options
  • Save Fleker/2bb34c8b164154aef07d24eee77ac548 to your computer and use it in GitHub Desktop.
Save Fleker/2bb34c8b164154aef07d24eee77ac548 to your computer and use it in GitHub Desktop.
The original middleware
type Conv = DialogflowConversation<TabletopAudioSession>
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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment