Parsing
Parsing enables your agent to understand human-like requests and translate them into precise skill with defined parameters that can be used by the handler.
Overview
For parsing to be effective we need to combine the following skills:
- Definition: Define skills, parameters and handlers.
Example
Imagine your users chatting with your agent as naturally as texting a friend.
Parsed request
/check vitalik.eth
Handler
The handler function to process check skill requests:
src/handlers/check.ts
export async function handleCheck(context: XMTPContext) {
const {
message: {
content: {
params: { domain },
},
},
} = context;
const data = await getUserInfo(domain);
if (!data?.address) {
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
return {
code: 200,
message,
};
} else {
let message = `Looks like ${domain} is already registered!`;
await context.executeSkill("/cool " + domain);
return {
code: 404,
message,
};
}
}