Build bottender bots with intent recognizer and action resolver.
npm install bottender-recognizer
(state, event) => intent | undefined
Example:
async (state, intent) => ({
name: 'INTENT_NAME',
payload: {},
});
name
- Must have.payload
- Recommended.
Example:
{
name: "INTENT_NAME",
payload: {}
}
(state, intent) => action
Example:
(state, intent) => doSomething;
With derivedState
and derivedParam
:
(state, intent) => derivedState + derivedParam + action
Example:
(state, intent) => ({
action: doSomething,
derivedState: {
x: 1,
},
derivedParam: {
y: 2,
},
});
context => void
Example:
async context => {
// ...
};
With parameters:
context + param => void
Example:
async (context, param) => {
// ...
};
It creates a bottender handler function.
createHandler({
recognizer,
resolver,
chatbase: {
apiKey: process.env.CHATBASE_KEY,
platform: 'Facebook',
},
debug: true,
});
It turns an array of recognizers into a single recognizer that you can pass to createHandler
.
const regex = (state, event) => {
if (event.isText && /^Hi$/i.test(event.text)) {
return {
name: 'GREETING',
payload: {
// other args...
},
};
}
};
const nlu = async (state, event) => {
//...
};
combineRecognizers([regex, nlu]);
MIT © Yoctol