-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabilities.ts
More file actions
35 lines (33 loc) · 869 Bytes
/
abilities.ts
File metadata and controls
35 lines (33 loc) · 869 Bytes
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
import { Ability } from 'wolf-core'
import { ConversationData } from './bot'
import { StorageLayerType } from '../../src'
export const abilities = [
{
name: 'greet',
traces: [
{
slotName: 'name'
}
],
onComplete: async (submittedData, {save}) => {
const newState = {
name: submittedData.name
}
await save(newState)
return `hi ${submittedData.name}!`
}
},
{
name: 'echo',
traces: [],
onComplete: async (submittedData, {read}, {getMessageData}) => {
const convoState = await read()
const messageData = getMessageData()
const message = messageData.rawText
if (convoState.name) {
return `${convoState.name} said "${message}"`
}
return `You said "${message}"`
}
}
] as Ability<ConversationData, StorageLayerType<ConversationData>>[]