Context
The "context" object is a key component within the framework that provides developers with access to essential information about the ongoing interaction between the user and the bot. This information includes default properties like from
(representing the sender) and body
(containing the message or input from the user).
When utilizing the framework's addAnswer and addAction methods, the context object is passed as the first argument in the callback functions. This allows developers to access and manipulate the context's properties dynamically, enabling tailored responses and actions based on the specifics of each user interaction.
import { addKeyword } from '@builderbot/bot';
const flowA = addKeyword('register')
.addAnswer('What is your name?', { capture: true }, async (ctx, { state }) => {
const responseName = ctx.body
const nameFrom = ctx.name
const numberFrom = ctx.from
console.log(`Other properties:`, ctx)
})
export default flowA
It is important to note that the properties you will always have available are from, body, name but you will also have many more different properties depending on the provider.