UNPKG

dashbot

Version:
45 lines (38 loc) 1.22 kB
/* Copyright (c) 2016-2019 Dashbot Inc All rights reserved */ 'use strict'; if (!process.env.DASHBOT_API_KEY_GENERIC) { throw new Error('"DASHBOT_API_KEY_GENERIC" environment variable must be defined'); } const dashbot = require('../src/dashbot')(process.env.DASHBOT_API_KEY_GENERIC, {debug:true, urlRoot: process.env.DASHBOT_URL_ROOT}).generic var readline = require('readline'); var rl = readline.createInterface({ input: process.stdin, output: process.stdout }); function ask(question) { const messageForDashbot = { "text": question, "userId": "USERIDHERE123123", "platformJson": { "whateverJson": "any JSON specific to your platform can be stored here" } }; dashbot.logOutgoing(messageForDashbot); rl.question(question, function(answer) { const messageForDashbot = { "text": answer, "userId": "USERIDHERE123123", "platformJson": { "whateverJson": "any JSON specific to your platform can be stored here" } }; dashbot.logIncoming(messageForDashbot); if (answer === 'quit') { rl.close(); return; } ask('You are right when you say: ' + answer + '. What else? '); }); } ask('Tell me your thoughts: ');