-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (106 loc) · 6.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>Introduction</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul class="sections">
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-comment">#!/usr/bin/env coffee</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<h1 id="introduction">Introduction</h1>
<p>This is an introduction to the bot
hey</p>
</div>
<div class="content"><div class='highlight'><pre>prompt = <span class="hljs-built_in">require</span> <span class="hljs-string">'prompt'</span>
Promise = <span class="hljs-built_in">require</span> <span class="hljs-string">'bluebird'</span>
Promise.promisifyAll prompt</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p>Make an object to hold the answers</p>
</div>
<div class="content"><div class='highlight'><pre>
answers = {}
ADDRESS = process.env.ADDRESS <span class="hljs-keyword">or</span> <span class="hljs-string">"You can also email us at sales@green-bot.com"</span>
HOURS = process.env.HOURS <span class="hljs-keyword">or</span> <span class="hljs-string">"We are open from 9 to 5 Monday through Friday"</span>
PROMPT_1 = process.env.PROMPT_1 <span class="hljs-keyword">or</span> <span class="hljs-string">"Thank you for texting in and trying out KISST4INFO, a simple way for your customers to contact your business using text and social messaging."</span>
PROMPT_2 = process.env.PROMPT_2
SIGNATURE = process.env.SIGNATURE <span class="hljs-keyword">or</span> <span class="hljs-string">"Thank you, you can visit us on the web at http://www.green-bot.com"</span>
SPECIALS = process.env.SPECIALS <span class="hljs-keyword">or</span> <span class="hljs-string">"Do you want to become a dealer for KISST Services? Or do you want to use it for your business? Call or text 508-364-9972 to discuss your needs"</span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p>Prompt is synchronous, no need for promises.</p>
</div>
<div class="content"><div class='highlight'><pre>prompt.start()
prompt.message = <span class="hljs-string">''</span>
prompt.delimiter = <span class="hljs-string">''</span>
<span class="hljs-function">
<span class="hljs-title">recordAnswer</span> = <span class="hljs-params">(key, value)</span> -></span>
answers[key] = value
<span class="hljs-built_in">console</span>.log JSON.stringify answers</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>Submit the first two prompts</p>
</div>
<div class="content"><div class='highlight'><pre>
<span class="hljs-built_in">console</span>.log PROMPT_1
<span class="hljs-built_in">console</span>.log PROMPT_2 <span class="hljs-keyword">if</span> PROMPT_2?
choicesSchema =
description: <span class="hljs-string">'How can I help you (address, hours, specials, contact, quit)?'</span>
type: <span class="hljs-string">'string'</span>
pattern: <span class="hljs-regexp">/address|hours|specials|contact|quit/i</span>
message: <span class="hljs-string">'Choice must be address, hours, specials, contact or quit.'</span>
required: <span class="hljs-literal">true</span>
before: <span class="hljs-function"><span class="hljs-params">(value)</span> -></span> value.toLowerCase()
<span class="hljs-function">
<span class="hljs-title">handleChoice</span> = -></span>
prompt.getAsync(choicesSchema).<span class="hljs-keyword">then</span> (result) ->
answer = result.question
recordAnswer <span class="hljs-string">'choice'</span>, answer
<span class="hljs-keyword">switch</span> answer
<span class="hljs-keyword">when</span> <span class="hljs-string">"hours"</span> <span class="hljs-keyword">then</span> <span class="hljs-built_in">console</span>.log HOURS
<span class="hljs-keyword">when</span> <span class="hljs-string">"address"</span> <span class="hljs-keyword">then</span> <span class="hljs-built_in">console</span>.log ADDRESS
<span class="hljs-keyword">when</span> <span class="hljs-string">"contact"</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"Thank you - we'll get back in touch as soon as possible"</span>
recordAnswer(<span class="hljs-string">"contactMe"</span>, <span class="hljs-string">"true"</span>)
answer
.<span class="hljs-keyword">then</span> (answer) ->
<span class="hljs-keyword">if</span> answer <span class="hljs-keyword">is</span> <span class="hljs-string">'quit'</span>
prompt.stop()
<span class="hljs-keyword">return</span>
<span class="hljs-keyword">else</span>
handleChoice()
handleChoice().<span class="hljs-keyword">then</span> ->
<span class="hljs-built_in">console</span>.log SIGNATURE</pre></div></div>
</li>
</ul>
</div>
</body>
</html>