This file was deleted.

This file was deleted.

@@ -2,7 +2,6 @@
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
import * as express from "express"
import * as logger from "winston"

// Local Dependencies
import './env'
@@ -12,9 +11,6 @@ import auther from './logic/auther'
// opiAI
// A bot that collections opinions.

// serving ============================================================
admin.initializeApp(functions.config().firebase)

// initializing =======================================================
const bot = express();

@@ -46,6 +42,55 @@ bot.post('/webhook/', (req: express.Request, res: express.Response) => {
})
})

// saving =============================================================
var db = admin.firestore();

var docRef = db.collection('surveys').doc('survey_0').set({
"postback": "survey_0",
"questions": [{
"quick_replies": [{
"content_type": "text",
"image_url": "",
"payload": 0,
"title": "You collect what?"
}, {
"content_type": "text",
"image_url": "https://i.imgur.com/Qwca6NZ.png",
"payload": 0,
"title": "Hi Opi!"
}],
"text": "Hello, my name is Opi. I collect opinions!"
}, {
"quick_replies": [{
"content_type": "text",
"image_url": "https://i.imgur.com/Qwca6NZ.png",
"payload": 1,
"title": "Yes"
}, {
"content_type": "text",
"image_url": "http://petersfantastichats.com/img/green.png",
"payload": 1,
"title": "Duh?"
}],
"text": "Do you know how to hit buttons?"
}, {
"quick_replies": [{
"content_type": "text",
"payload": 2,
"title": "😂"
}, {
"content_type": "text",
"payload": 2,
"title": "😛"
}],
"text": "Welcome to Feedback!"
}]
})
.then(ref => {
console.log("saved!")
})



// notifying ==========================================================
console.log("Opi alive!")
@@ -1,3 +1,16 @@
// Loads environment variables
import * as dotenv from 'dotenv'
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'

// process.env
dotenv.config()

// firebase
admin.initializeApp(functions.config().firebase)

// Helper functions

//

// import { } from 'dotenv/config';
File renamed without changes.
@@ -2,19 +2,21 @@

// Package Dependencies
import { database } from 'firebase-admin'
import * as logger from 'winston'

// Local Dependencies
import { sendMessage, sendTextMessage } from './sender'
import { surveys, users, responses } from './saver'

/** Saves new users in Firebase
/** Saves new users in Database
* @param {string} userID - Facebook user ID
*/
export async function saveUser(userID: string) {
console.log('Saving User %d in the Database...', userID);
database.ref('users/' + userID).set({
availableSurveys: {},
});
users
.doc(userID)
.set({
availableSurveys: {},
});
};

/** Checking if the user exists in the database
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,14 @@
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'

// Firestore Database
const db = admin.firestore()

// `responses/` endpoint
export const responses = db.collection("responses")

// `survey/` endpoint
export const surveys = db.collection("surveys")

// `users/` endpoint
export const users = db.collection("users")
File renamed without changes.

This file was deleted.

@@ -0,0 +1,14 @@
<html>

<head>
<title>Facebook Messenger Bot</title>
</head>

<body>
<h1>Facebook Messenger Bot</h1>This is a bot based on Messenger Platform QuickStart. For more details, see their
<a href=\ "https://developers.facebook.com/docs/messenger-platform/guides/quick-start\">docs</a>.
<script src=\ "https://button.glitch.me/button.js\" data-style=\ "glitch\"></script>
<div class=\ "glitchButton\" style=\ "position:fixed;top:20px;right:20px;\"></div>
</body>

</html>