0

I'm working on a Dialogflow chatbot, and I'm currently giving the response hard coded in fulfillment using agent.add(). However, the product owner wants to be able to modify the wordings without having to change and redeploy code. What are the options for this, other than storing responses in a file or in a database? Is there a way to have variables in the response when you add it in the response section in the Dialogflow console, where that variable is set in fulfillment, but otherwise the response is given as per the response in the console? Is there a way to select which response is given out of the ones set in the Dialogflow console from fulfillment? I'm using the nodejs fulfillment library without actions on google.

  • Little explanation and too many questions! It would be better if you could be more specific with some examples of what you are trying to achieve. Why not use Response under Intents on Dialogflow? – Gray_Rhino Nov 14 '19 at 05:55
  • I would like to use Response under Intents as the Dialogflow console as you're suggesting. I want to know if it is possible to use variables there inside the response string that can be manipulated from fulfillment, or choose a response to give out of the ones listed there from fulfillment. Normally one of those responses is chosen randomly. – ErraticEggplant Nov 14 '19 at 07:22
  • Yes it is possible. You can create custom parameter and entities and access them from code behind. Just keep in mind that when you "Enable webhook call for this intent" and if you want to add response both in intent and in fulfillment, the one in intent will act as a back up. It will be triggered only if response in fulfillment fails. – Gray_Rhino Nov 14 '19 at 08:39

1 Answers1

0

I think you have two options:

  1. Use one intent only with various parameters

    You can have multiple variants of responses in one intent. These will be prioritized by the maximum parameters they can fill. For example, if you are sending parameter "a" to a single intent using detectIntent API, the second response here will be triggered and shown to the user.

    This is a response1 without parameters
    This is a response1 with parameter $a <-- This will be triggered
    This is a response1 with parameter $a and $b

    As a little hack, you can also send an empty unicode space character here, if you prefer not to generate any parameters on the backend. Not too clean, but would work.

  2. Use events triggered from your backend

    In this case, your webhook/backend would choose a proper event to call. Hence, you would have mutliple intents, each with a unique response. You can also combine this approach with the first point above. You can read more about events here.

flaesh
  • 262
  • 5
  • 17