I have a dialogflow fulfillment service/webhook service that needs to reach into a backend database to pull some data out for a response. The problem is I have to query this database with a specific identifier, is there anyway to pass in a unique identifier when we make a request to dialogflow from a chatbox or a speech request?
In Dialogflow you can send input from chatbox to webhook using query input as well as context.
In your case it make more sense that you pass the data using context in request itself to get the data in webhook.
Related
New to creating Webhooks and DialogFlow chatbots. I have created a nodejs Webhook in Visual Studios to enable fulfilment in Dialogflow. However, when I have multiple users using the chatbot at the same time, the parameters in the Webhook (not parsed from Dialogflow) are shared among users. How do I alter the Webhook such that each user has their own set of parameters? I am using the Telegram integration in Dialogflow.
The parameters coming from the dialogflow are distinct for each session. If you are storing and modifying the parameters from your webhook locally, you need to use the session id as the unique key for each conversation.
I need to edit request before sending it to endpoint.
Using Web Demo integration I'm able to send request to the endpoint.
But I can't edit the request in order to provide some extra data to request. Extra data is stored in localStorage so I need to do this in javascript.
I've already connected the agent to an endpoint that handle the request using fullfillment. The problem is that request misses data I can retrieve only from the browser. From fullfillment I can set headers and basic auth but statically and it is not enough.
So I need to add a step in request building/sending:
User write or tell something to embedded chat (Web Demo integration)
Dialogflow recognize intent, params, generate the request.
Additional step: Update the request in javascript
Forward cutomized request to the endpoint
Maybe it's not possible using Web Demo integration. In Documentation can't find a way to just send string or audio in order to receive the generated request.
First of all you will need a custom chat integration, not the default Dialogflow one. Something like Smooch or Kommunicate. The default web demo should only be used for testing your bot. There is NO way you would want to use that in a production environment.
I would save whatever is in the local storage in a database such as Firestore. Once that data is in the database you can use it to modify your request in your fulfillment.
So what I would do:
Have a way to identify a user and save its local storage to the database (as soon as someone clicks on your chat window or opens the chat window)
Once an intent is triggered you check which user is contacting you (through the way that you identified the user) and get all data from the database
Request the data in your fulfillment server
There is no other way in which this is possible. You can't change requests before your query hits Dialogflow.
Im using fulfillment to get data from database. And I have integrated my bot with facebook.
And currently I'm customizing db response as per facebook in my api itself and sending it to the dialogflow.
And I want to integrate it with skype too.
Now my question is, can I customise my api response in dialogflow instead of in API. As I want to integrate my bot with multiple platforms so accordingly their response will be formatted as per facebook or skype.
So i will need to create another api for skype too. I want to avoid this.
So I want to get output from my api and format it in dialogflow itself using custom payload. So is it possible to work in this way?
Sure! You get the stored data using your API and then you format the response for the platforms you are going to use. In this example, the payload contains different responses for Google Assistant, Facebook and Slack.
Also, take a look at this NodeJS library which makes easier develop your fulfillment code.
I have created an intent with an event. I'm sending a POST request as described in the docs with the proper sessionId (that corresponds to my conversation with my Bot On Slack)
When I send the request, the intent is triggered and the response to my request is correct, but there is no message displayed on Slack. I have double-checked the session, it is correct as I have put a context with some values that I can get back in my request's reponse.
Unfortunately it's not possible to send requests to dialogflow to display a message for the user. Your service (slack in this case) can send a query to dialogflow from a user input and then print the response, not the other way around.
What you could do instead is to add another endpoint to slack where your fulfillment can send messages directly to slack. In that case the fulfillment could send a query to dialogflow to get a formatted response and then send the response to slack.
I have a question. Is it possible to use both flowXO and API.ai together and single-time in one bot? If so, how to implement it?
You can integrate Flow XO to API.ai To understand a user’s intent.
Send HTTP request to APi.ai. By Post method you can pass query with some authentication data in header. Dialogflow resolve this query and give you response in JSON format. You can directly use this data in flow.
You can find step by step instruction in below link.
Using Flow XO with Dialogflow