Overview
TheaddKeyword function creates a new conversation flow that is triggered when a user sends a message matching the specified keywords or regex pattern. This is the entry point for creating conversation flows.
Function Signature
Parameters
The keyword(s) that trigger this flow. Can be:
- A single string:
'hello' - An array of strings:
['hello', 'hi', 'hey'] - A regex pattern (when
options.regexistrue)
Optional configuration for keyword matching behavior.
Return Value
Returns a flow object with the following methods:
Usage Examples
Basic Keyword Trigger
- TypeScript
- JavaScript
Multiple Keywords
- TypeScript
- JavaScript
Case-Sensitive Matching
- TypeScript
- JavaScript
Regex Pattern Matching
- TypeScript
- JavaScript
Complex Flow with Actions
- TypeScript
- JavaScript
Common Patterns
Menu Flow
Help Command
Notes
- Keywords are matched against the entire message body by default
- When using multiple keywords, any match will trigger the flow
- Regex patterns must be properly escaped in strings
- Case-insensitive matching is the default behavior
- The flow is only triggered once per keyword match per message
Related
- addAnswer - Add responses to your flow
- addAction - Add callback actions
- createFlow - Combine multiple keyword flows