Skip to content

Instantly share code, notes, and snippets.

View savelee's full-sized avatar

Lee Boonstra savelee

View GitHub Profile
@savelee
savelee / index.html
Created December 6, 2019 17:20
A best practice for streaming audio from a browser microphone to Dialogflow or Google Cloud STT by using websockets.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>RecordRTC over Socket.io</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="https://www.WebRTC-Experiment.com/RecordRTC.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
@savelee
savelee / index.js
Created January 11, 2023 08:32
Example Dialogflow CX webhook as Node JS cloud function
const functions = require('@google-cloud/functions-framework');
// Here's where you set the entry point, it gets the request from Dialogflow CX
// and it holds the response which will be sent back to Dialogflow
functions.http('orderState', (req, res) => {
let msg;
let results = {};
//let item;
//Let's log whatever we receive from Dialogflow CX to understand things better
@savelee
savelee / app.js
Last active August 18, 2022 09:46
Actions on Google for Google Cloud Functions
'use strict';
const {
dialogflow
} = require('actions-on-google'); //version 2.1.1
const assistantHandler = (conv) => {
console.log('Dialogflow Request headers: ' + JSON.stringify(conv.headers));
console.log('Dialogflow Request body: ' + JSON.stringify(conv.body));
@savelee
savelee / _index.js
Last active August 18, 2022 09:45
Actions on Google starter template (firebase)
'use strict';
const functions = require('firebase-functions');
const {
dialogflow,
Suggestions,
Image,
BasicCard,
MediaObject,
List,
@savelee
savelee / index.js
Last active August 18, 2022 09:43
Conditional Templating in Dialogflow with Custom Payloads and Google Cloud Functions
'use strict';
const {
dialogflow
} = require('actions-on-google');
const pug = require('pug');
/*
* Uses Pug.js https://pugjs.org/language/plain-text.html
* Requires a Dialogflow custom payload like:
@savelee
savelee / chatserver-node.js
Last active August 18, 2022 09:40
Example Dialogflow implementation, branching on parameters and returning text strings
require('dotenv').config() //load environemnt vars
const projectId = process.env.GCLOUD_PROJECT; //your project name
const uuidv1 = require('uuid/v1');
const sessionId = uuidv1();
const languageCode = 'en-US';
const server = require('http').createServer((request, response) => {
response.writeHead(200, {"Content-Type": "text/html"});
@savelee
savelee / index.js
Last active August 18, 2022 09:38
Dialogflow Fulfillment Library
'use strict';
const functions = require('firebase-functions');
const { WebhookClient, Card, Suggestion } = require('dialogflow-fulfillment');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
@savelee
savelee / .sh
Last active March 17, 2022 19:29
Run Sencha Test with Webdriver
//run webdriver:
java -jar selenium-server-standalone-2.53.0.jar
//run test archiver
//this requires a TestArchiveStorage folder with a storage.json file
//from ST Studio interface, you will have to add a browser to the pool
cd ~/bin/Sencha/TestArchiveStorage
stc server
@savelee
savelee / .dockerignore
Last active January 31, 2022 20:54
Dialogflow Fulfillment in Cloud Run
Dockerfile
README.md
node_modules
npm-debug.log
@savelee
savelee / json.json
Created February 21, 2020 13:23
Custom Payload Hangouts example
{
"hangouts": {
"header": {
"title": "Pizza Bot Customer Support",
"subtitle": "pizzabot@example.com",
"imageUrl": "https://goo.gl/aeDtrS"
},
"sections": [
{