I am currently using api.ai , to create agent to perform specific tasks, but one question i don’t have answer to is , can i make it learn something while chatting , mean that i speak my name is ‘John Cena’ and she should store it and then whenever i ask her again bot should answer me that. i know there is a way to do it by logging into api.ai web and manually add entries , but it will not help, is there any work around programmatically or automatically ? the file i’ve been using to practice is given in github . and here is working DEMO
Share
I hear you, manually adding entries in api.ai (now Dialogflow) for every new piece of information can get tedious fast. Here’s how you can make your agent learn dynamically during chats, just like you want it to remember your name is John Cena!
There are two main approaches:
1. Using Webhooks:
Webhooks are a powerful way to extend your agent’s capabilities. Here’s the idea:
This feels a lot like John Cena’s entrance music – dramatic reveal of a stored fact!
2. Using Contexts:
Contexts are a built-in feature in Dialogflow that allows you to store temporary information about the conversation. This approach works well if you only need to remember user information within a single session.
Here’s the breakdown:
Here’s an example of using a webhook (approach 1):
Your webhook program could be written in Python and utilize a simple library like
sqlite3to store data in a local database. Here’s a simplified example (remember, this requires additional coding):Both approaches have their pros and cons. Webhooks offer more flexibility and persistence, while contexts are simpler to implement but lose information across sessions.
Remember, the example code snippet here is just a starting point. You’ll need to adapt it to your specific needs and chosen programming language.