Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hubot-natural
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
hubot-natural
Commits
9e3d750b
Commit
9e3d750b
authored
7 years ago
by
Diego Dorgam
Browse files
Options
Downloads
Patches
Plain Diff
adding livechatTransfer method to respond.coffee
parent
d166f706
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scripts/bot/index.coffee
+9
-23
9 additions, 23 deletions
scripts/bot/index.coffee
scripts/events/respond.coffee
+17
-2
17 additions, 2 deletions
scripts/events/respond.coffee
training_data/catbot-en.yml
+109
-95
109 additions, 95 deletions
training_data/catbot-en.yml
with
135 additions
and
120 deletions
scripts/bot/index.coffee
+
9
−
23
View file @
9e3d750b
...
...
@@ -41,6 +41,7 @@ sendWithNaturalDelay = (msgs, elapsed=0) ->
delay
=
Math
.
min
(
Math
.
max
((
msg
.
length
/
keysPerSecond
)
*
1000
-
elapsed
,
0
),
maxResponseTimeInSeconds
*
1000
)
typing
@
,
true
setTimeout
=>
@
send
msg
...
...
@@ -51,21 +52,13 @@ sendWithNaturalDelay = (msgs, elapsed=0) ->
cb
?
()
,
delay
# check these
livechatTransferHuman
=
(
res
)
->
setTimeout
->
res
.
robot
.
adapter
.
callMethod
'livechat:transfer'
,
roomId
:
res
.
envelope
.
room
departmentId
:
process
.
env
.
DEPARTMENT_ID
,
1000
setUserName
=
(
res
,
name
)
->
res
.
robot
.
adapter
.
callMethod
'livechat:saveInfo'
,
_id
:
res
.
envelope
.
user
.
id
name
:
name
,
_id
:
res
.
envelope
.
room
#
# setUserName = (res, name) ->
# res.robot.adapter.callMethod 'livechat:saveInfo',
# _id: res.envelope.user.id
# name: name
# ,
# _id: res.envelope.room
# #
classifyInteraction
=
(
interaction
,
classifier
)
->
if
Array
.
isArray
interaction
.
expect
...
...
@@ -247,17 +240,10 @@ module.exports = (_config, _configPath, robot) ->
msg
=
res
.
match
[
0
].
replace
res
.
robot
.
name
+
' '
,
''
msg
=
msg
.
replace
(
/^\s+/
,
''
)
msg
=
msg
.
replace
(
/\s+&/
,
''
)
# console.log '\n\n'
# console.log JSON.stringify(res.robot)
# console.log '\n\n'
console
.
log
JSON
.
stringify
(
res
.
message
)
console
.
log
'
\n\n
'
console
.
log
JSON
.
stringify
(
res
.
envelope
)
console
.
log
'
\n\n
'
# check if robot should respond
if
res
.
envelope
.
user
.
roomType
in
[
'c'
,
'p'
]
if
(
res
.
message
.
text
.
match
new
RegExp
(
'
\\
b'
+
res
.
robot
.
name
+
'
\\
b'
,
'i'
))
or
(
res
.
message
.
text
.
match
new
RegExp
(
'
\\
b'
+
res
.
robot
.
alias
+
'
\\
b'
,
'i'
))
processMessage
res
,
msg
# TODO: Add engaged user conversation recognition
# TODO: Add engaged user conversation recognition
/tracking
else
if
res
.
envelope
.
user
.
roomType
in
[
'd'
,
'l'
]
processMessage
res
,
msg
This diff is collapsed.
Click to expand it.
scripts/events/respond.coffee
+
17
−
2
View file @
9e3d750b
...
...
@@ -3,19 +3,34 @@ natural = require 'natural'
{
msgVariables
,
stringElseRandomKey
}
=
require
path
.
join
'..'
,
'lib'
,
'common.coffee'
answers
=
{}
livechat_department
=
(
process
.
env
.
LIVECHAT_DEPARTMENT_ID
||
null
)
class
respond
constructor
:
(
@
interaction
)
->
process
:
(
msg
)
=>
action
=
@
interaction
.
action
?
.
toLowerCase
()
or
false
switch
action
when
'transfer'
@
livechatTransfer
(
msg
)
type
=
@
interaction
.
type
?
.
toLowerCase
()
or
'random'
switch
type
when
'block'
messages
=
@
interaction
.
answer
.
map
(
line
)
->
return
msgVariables
line
,
msg
msg
.
sendWithNaturalDelay
messages
msg
.
sendWithNaturalDelay
messages
,
0
,
action
when
'random'
message
=
stringElseRandomKey
@
interaction
.
answer
message
=
msgVariables
message
,
msg
msg
.
sendWithNaturalDelay
message
msg
.
sendWithNaturalDelay
message
,
0
,
action
livechatTransfer
:
(
msg
)
->
setTimeout
(
->
msg
.
robot
.
adapter
.
callMethod
(
'livechat:transfer'
,
roomId
:
msg
.
envelope
.
room
departmentId
:
livechat_department
).
then
(
result
)
->
console
.
log
'livechatTransfer executed! '
+
result
),
3000
module
.
exports
=
respond
This diff is collapsed.
Click to expand it.
training_data/catbot-en.yml
+
109
−
95
View file @
9e3d750b
...
...
@@ -87,8 +87,7 @@ interactions:
-
Ok, I'm transfering this to a real person.
-
one moment please.
event
:
respond
context
:
clear
action
:
tranfer
action
:
transfer
type
:
block
-
name
:
greeting-help
...
...
@@ -122,6 +121,99 @@ interactions:
context
:
clear
event
:
respond
type
:
block
-
name
:
greeting-how-are-you
expect
:
-
How are you?
-
How are doing?
-
How are you feeling?
answer
:
-
I am great, $user. Everything is peaceful around here...
-
How can I be useful to you?
event
:
respond
type
:
block
-
name
:
greeting-miss-you
expect
:
-
long time no see
-
I missed you
-
did you miss me
-
do you remember me
answer
:
-
I missed you too...
-
$user! It's been a while!
-
I was starting to think you wouldn't remember me anymore =)
event
:
respond
type
:
random
-
name
:
greeting-answer
expect
:
-
I'm fine
-
I'm good
-
I'm great
answer
:
-
cool =)! How can I help you?
-
That's great!
-
Awesome
-
ok =)
event
:
respond
type
:
random
-
name
:
greeting-thankful
expect
:
-
Thanks
-
Thank you
-
awesome Thanks
-
thks
-
thank you very much
answer
:
-
you're welcome =) there is anything else?
-
great! if you need something else please feel free to ask
-
cool, glad to help.
event
:
respond
type
:
random
-
name
:
greeting-morning
expect
:
-
good morning
-
morning
-
morning bot
-
good morning bot
answer
:
-
Hello, $user. I wish you a great day!
-
Good morning, $user. How's the weather outside?
-
It's a beatiful day to surf on the internert
-
So great, $user ;)
-
It's all better now that you got here, $user
event
:
respond
type
:
random
-
name
:
greeting-afternoon
expect
:
-
afternoon
-
good afternoon
answer
:
-
Hellos, $user! i wish you a fantastic afteroon!
-
Good afternoon, $user. Did you have lunch already?
-
It's a beautiful afternoon for a quick sleep mode ;)
-
Good afternooooon, $user!
-
$user, I was starting to miss you already
event
:
respond
type
:
random
-
name
:
greeting-night
expect
:
-
good night
-
good evening
-
night
-
evening
answer
:
-
A very good night to you as well, $user!
-
Good night, $user!
-
It is truely a good night, $user
event
:
respond
type
:
random
# RocketChat Installation
-
name
:
install-intro
...
...
@@ -1131,104 +1223,12 @@ interactions:
-
son of a bitch
answer
:
-
whaaaat? you don't need to be rude, I'm just a machine..
-
Oh yeh?! but at least my mother-board teached better..
-
Oh yeh?! but at least my mother-board teached
me
better..
-
You touch people with those fingers?
-
sorry $user, I'm only an experimental bot...
event
:
respond
type
:
random
-
name
:
greeting-how-are-you
expect
:
-
How are you?
-
How are doing?
-
How are you feeling?
answer
:
-
I am great, $user. Everything is peaceful around here...
-
How can I be useful to you?
event
:
respond
type
:
block
-
name
:
greeting-miss-you
expect
:
-
long time no see
-
I missed you
-
did you miss me
-
do you remember me
answer
:
-
I missed you too...
-
$user! It's been a while!
-
I was starting to think you wouldn't remember me anymore =)
event
:
respond
type
:
random
-
name
:
greeting-answer
expect
:
-
I'm fine
-
I'm good
-
I'm great
answer
:
-
cool =)! How can I help you?
-
That's great!
-
Awesome
-
ok =)
event
:
respond
type
:
random
-
name
:
greeting-thankful
expect
:
-
Thanks
-
Thank you
-
awesome Thanks
-
thks
-
thank you very much
answer
:
-
you're welcome =) there is anything else?
-
great! if you need something else please feel free to ask
-
cool, glad to help.
event
:
respond
type
:
random
-
name
:
greeting-morning
expect
:
-
good morning
-
morning
-
morning bot
-
good morning bot
answer
:
-
Hello, $user. I wish you a great day!
-
Good morning, $user. How's the weather outside?
-
It's a beatiful day to surf on the internert
-
So great, $user ;)
-
It's all better now that you got here, $user
event
:
respond
type
:
random
-
name
:
greeting-afternoon
expect
:
-
afternoon
-
good afternoon
answer
:
-
Hellos, $user! i wish you a fantastic afteroon!
-
Good afternoon, $user. Did you have lunch already?
-
It's a beautiful afternoon for a quick sleep mode ;)
-
Good afternooooon, $user!
-
$user, I was starting to miss you already
event
:
respond
type
:
random
-
name
:
greeting-night
expect
:
-
good night
-
good evening
-
night
-
evening
answer
:
-
A very good night to you as well, $user!
-
Good night, $user!
-
It is truely a good night, $user
event
:
respond
type
:
random
# Configuration
-
name
:
configure-debug
expect
:
...
...
@@ -1261,3 +1261,17 @@ interactions:
type
:
random
action
:
train
role
:
admin
-
name
:
configure-livechat
expect
:
-
"
configure
livechat-"
-
"
set
livechat-"
-
"
var
livechat-"
answer
:
-
$key changed to $value!
-
Got it! Now $key is $value
-
$key = $value -> https://media.giphy.com/media/12NUbkX6p4xOO4/giphy.gif
event
:
configure
type
:
random
action
:
setVariable
role
:
admin
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment