This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
[Discussion] Proposed API changes for next version #143
Labels
Feature Request
New feature or request
Hey, Dialogflow team & community --
I recently built a production Twilio chatbot using Dialogflow and I wanted to share some feedback/ideas based on my experience. I'd like to use this thread as a place to discuss these ideas and will make issues/pull requests for the ones that have traction. Some of these may be service level API level changes, so if you think there's a better place to share them please let me know.
Excited to hear your thoughts and questions!
1. Implement a real router
Problem:
Right now you only have two major routing options - a single function or a
Map
between intent names and functions. The single function works well for simple apps, but doesn't scale well when your application becomes more complex. The Map scales a bit better, especially when you have discrete logic for each intent, but it breaks easily because it's based solely on an exact match with the name of the intent. Things get more complicated when you have several intents that all represent a single action, but have slightly different names (Ex. "Welcome Intent (Logged In)" & "Welcome Intent (Logged Out)").Proposed Solution:
route.intent('^Welcome Intent - (.*)', handleWelcomeIntent)
)route.action('welcome-action', handleWelcomeIntent)
orroute.event('welcome', handleWelcomeIntent)
)2. Add Middleware Support
Problem:
Some of my intents would benefit from being able to run a series of functions to manipulate the agent before it is passed to the ultimate handler. Use cases include authentication, calling other APIs/services, etc. Right now the only way to do this is to write increasingly complex handler functions.
Proposed Solution:
app.use( (agent, next) => { /* Login Logic */ })
).(Ex.
route.action('welcome-action', [middelware1, middleware2], handleWelcomeIntent)
)3. Update the outgoing message logic
Problem:
The way that messages are sent is not intuitive. This libray only allows a single predefined response, but the dialogflow GUI will randomly select one from a list. This library also doesn't allow sending mutliple messages, which is a common pattern. Futher, the default console messages are completely ignored and would be a great default set of responses to fall back on.
Proposed Solution:
agent.add(msg)
calls should send multiple messages.(Ex.
agent.say([msg1, msg2, msg3])
should randomly send one of those messages, which is what the Dialogflow GUI does).consoleMessages
if no new response was added. If I never callagent.add
, then why shouldn't the bot respond the way it intended to?The text was updated successfully, but these errors were encountered: