Dialogflow - display message with request to /query - dialogflow-es

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.

Related

Sending custom data to dialogflow

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.

How to send text message through DialogFlow?

I tried looking all over the internet on how to setup and send text message(sms) through Dialogflow.
I am building an app where the Bot asks the user for their number and sends them a text message. Is there a tutorial? or anyone guide me I appreciate it?
As suggested by Nikhil, you need to use twillio APIs to send the SMS.
Here is how it will work:
Dialogflow will ask user for phone number and store it in a parameter
Dialogflow will pass the phone number to the Webhook
The Webhook will make an API call to the Twillio API with above phone number
Twillio will send the sms
Webhook can return some success message to the Dialogflow
Dialogflow will return the message to the user.
Here is a link to the tutorial I have created for understanding dialogflow webhooks: https://www.youtube.com/watch?v=1cD9vU7Ubyg
You can refer to this link for sending sms in PHP via Twillio: sending sms via twilio in php

How does dialogflow chooses between static responses and webhook responses?

I am trying to build a bot service using google's dialogflow. I have already written an intent and that is having a web hook and static responses also. My question is how does dialogflow decides between static responses and whether to invoke the webhook?
If you have a webhook defined, and you have the "Enable webhook call for this intent" switched on, it will call the webhook. If your webhook returns a response, it will send that response to the user.
If you have the switch off, or if your webhook does not return anything (either because it times out or you choose not to send anything), then it will use the replies you have set in the Intent.

How do I get the auth token from api.ai to send message to slack?

I have a case where I need to create a Bot in Slack that my users can use conversational language to get information out of my web app in real time. The scenario goes something like:
User asks the bot something like: #hrbot How many employees are in the Finance department?
Bot send the string to API.AI/ diagflow to resolve into a JSON request
API.AI sends the JSON request to my Web App endpoint via webhook to get the answer
Answer is returned to user's Slack channel
Question:
1. How do I get the auth token from api.ai to send message to slack?
With Dialogflow (formerly API.AI) you provide a webhook (a HTTPS URL where your server is) and Dialogflow will send a HTTPS request to your webhook when requests come to your Dialogflow agent. You can enable the Slack integration in your Dialogflow agent through the web interface and all requests from Slack will be sent to your Dialogflow agent and (if you configure it) to your webhook with NLU information and the original request from Slack.
Information about the request that is sent to your webhook is documented here: dialogflow.com/docs/fulfillment#request if you respond to the request the response will be forwarded to the user that trigger the request. The response format is documented here: dialogflow.com/docs/fulfillment#response

How does webhooks get triggered in API.ai

I have an intent in which I have few responses and webhook enabled. I don't understand how the webhook gets triggered all the time and not the static responses mentioned within intent.
How does the API.ai differentiate when to trigger webhook and when to return static response.
Thanks,
Janmajay
API.AI allows you to connect to third party services using webhooks. If you enable the webhook, then the API.AI will always ask the webhook for the response and will show you the response received from webhook.
If for some reason, the webhook query failed, then only the static text response will be displayed.
If however, you don't want to use webhook and instead want to show the static response then you just need to uncheck the webhook checkbox. After that, the static response will be displayed to the user always.

Resources