Hey sorry for the late reply. I'm not sure I understand what you mean, but I'll answer what I understood.
When your fulfilment webhook is called the intent name will be in body.queryResult.intent.displayName you can use a switch case statement to check the name of the intent and perform some actions. You then have to return a webhook response for the request.
Hello @newton
, thank you very much for your answer!
I'm having trouble understanding which part of your project I should create this code that you informed.
I understand how the webhook should work, but I don't know where I put that part of the code that you passed.
I must create a new route in the bot.js file
router.post (/webhook, (request, response) => {}); ?
and then refer to BotController.ts?
With the code you passed?
Sorry for the long text, if you have any code examples that are working, you can share that I analyze and try to understand, thank you my friend!
When you receive the webhook from dialogflow, do whatever you need to do with the intent and parameters and then return the response to dialogflow. In BotController.ts, or wherever you execute the runQuery function, just await the result then send that to Whatsapp.
I have a web service that receives four input parameters and returns an object on the output, I need to return the value of that object to WhatsApp
My doubt is in which part of your project I put the code you passed, so when the dialogflow returns the parameters I make the call to the Webservice and use its output on WhatsApp
Thank you!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Newton, great article!
How can I identify the name of the itent that matched the dialogflow and give a specific answer?
I know the value in the dialogflow is at
body.intent.displayName, but how can I capture this value in the code to give a dynamic response?
Thank you!
Hey sorry for the late reply. I'm not sure I understand what you mean, but I'll answer what I understood.
When your fulfilment webhook is called the intent name will be in
body.queryResult.intent.displayName
you can use a switch case statement to check the name of the intent and perform some actions. You then have to return a webhook response for the request.Here's how you can do this in express
Please read more about this here cloud.google.com/dialogflow/docs/f...
Hello @newton , thank you very much for your answer!
I'm having trouble understanding which part of your project I should create this code that you informed.
I understand how the webhook should work, but I don't know where I put that part of the code that you passed.
I must create a new route in the bot.js file
router.post (/webhook, (request, response) => {}); ?
and then refer to BotController.ts?
With the code you passed?
Sorry for the long text, if you have any code examples that are working, you can share that I analyze and try to understand, thank you my friend!
Hi,
From my understanding, what you're looking to achieve is something like this:
I have updated the repo to include a controller for Dialogflow webhook. github.com/newtonmunene99/wa-chatbot
When you receive the webhook from dialogflow, do whatever you need to do with the intent and parameters and then return the response to dialogflow. In
BotController.ts
, or wherever you execute therunQuery
function, just await the result then send that to Whatsapp.Thank you so much @newton !
I'll look at it right now, have a great day my friend!
Hello, this is more or less what I need to do,
I have a web service that receives four input parameters and returns an object on the output, I need to return the value of that object to WhatsApp
My doubt is in which part of your project I put the code you passed, so when the dialogflow returns the parameters I make the call to the Webservice and use its output on WhatsApp
Thank you!