Skip to content

Instantly share code, notes, and snippets.

const express = require('express')
const bodyParser = require('body-parser')
const jsonParser = bodyParser.json()
const axios = require('axios');
const app = express()
app.post('/webhook', jsonParser, (req, res) => {
console.log(req.body)
for(const event of req.body.events) {
{
"type": "bubble",
"size": "giga",
"header": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "image",
"url": "https://tinman-asia.com/wp-content/uploads/2021/10/Layer_1.png",
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover"
/>
<title>LIFF: LINE Front-end Framework</title>
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
// Import stylesheets
import './style.css';
// Body element
const body = document.getElementById('body');
// Button elements
const btnSend = document.getElementById('btnSend');
const btnClose = document.getElementById('btnClose');
const btnShare = document.getElementById('btnShare');
import * as functions from "firebase-functions";
import * as dialogflow from "@google-cloud/dialogflow";
import axios from "axios";
const projectId = "<DIALOGFLOW PROJECTID>";
const LINE_HEADER_DEV = {
"Content-Type": "application/json",
"Authorization": "Bearer <DEV CHANNEL ACCESS TOKEN>",
};
const LINE_HEADER_PROD = {
import * as functions from "firebase-functions";
import * as dialogflow from "@google-cloud/dialogflow";
const projectId = "multiple-env-pafg";
// // 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";
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";
import * as functions from "firebase-functions";
// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
export const webHook = functions.https.onRequest((request, response) => {
console.log(request.body);
const events = request.body.events;
events.forEach( async (event: any) => {
console.log(event);
if (event.type === "message") {
// Handle events
events.forEach(async(event) => {
if (event.type === 'videoPlayComplete') {
await savePointVideoComplete(event)
}
console.log(event)
})
const admin = require("firebase-admin")
const functions = require("firebase-functions")
const region = 'asia-northeast1'
const channelSecret = ''
const channelAccessToken = ''
admin.initializeApp()