Skip to content

Instantly share code, notes, and snippets.

@PamornT
Created December 12, 2022 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PamornT/24d553b1cbdc34edee17f8664a1e8eef to your computer and use it in GitHub Desktop.
Save PamornT/24d553b1cbdc34edee17f8664a1e8eef to your computer and use it in GitHub Desktop.
import * as functions from "firebase-functions";
// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
let dialogflowEnv = "";
//
export const webHook = functions.https.onRequest((request, response) => {
if (request.body.destination === "U19476f0931c6ac37972a6b7f4b4321c6") {
dialogflowEnv = "draft";
} else if (request.body.destination === "U92a6f010a3fd78085b8763159a04772b") {
dialogflowEnv = "production";
}
const events = request.body.events;
events.forEach( async (event: any) => {
console.log(event);
if (event.type === "message") {
// Detect Intent
// Reply
}
});
response.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment