Problems with API.ai and Web Bot integration

(Janmajay Adhikari) #1

Thanks for API.ai tutorial. I went ahead and followed API.ai tutorial created a weather widget in API.ai console that fetches weather information from weather api via webhook. Also it returns static responses if user query(what user ask) is incomplete .

The FLOWXO tutorial suggest to use a catch all trigger in the Api.ai tutorial.

Problems faced are below.
1.) I have configured HTTPS webhook to hit API.ai and set the request RAW data as below. Ideally what ever I enter should be the value for “query” key in the request JSON as below.
{
“query”: [
“{{catchall.message}}”
],
“contexts”: [{
“name”: “location”,
“lifespan”: 4
}],
“lang”: “en”,
“sessionId”: “{{catchall.user_id}}”
}

But when I checked interaction logs, query parameter gets populated with “start” due to which I get a static response from API.ai agent even before the user have entered any text in the chat bot. Below is the request that goes to API.ai.

{
“query”: [
“start”
],
“contexts”: [{
“name”: “location”,
“lifespan”: 4
}],
“lang”: “en”,
“sessionId”: “ok2r3a”
}

2.) The response from API.ai is of two types static and dynamic(fetched from webhook that retires data from weather api) for both response type, json format is different.

for static response - RESPONSE JSON has result field that contains speech key whoose value should be displayed data__result__speech

for dynamic response - RESPONSE JSON has fulfillment field that contains speech key whoose value should be displayed.
data__fulfillment__speech

How can I set a output message in Send a Message flow action considering the fact that response JSON format is changing depending upon user input.

Thanks,
Janmajay

(Daniel Beckett) #2

@Janmajay

To handle the first problem you could add a Filter for {{catchall.message}} Does not equal ‘Start’

This will stop the catch-all from triggering on the ‘Get Started’ button.

For the second problem it looks like Filters could be the solution again but it’s tricky to say exactly how this would work without having some of the outputs to experiment with. Perhaps you could setup different output actions (send a message, send a card etc.) that are filtered based on your data output containing a particular value?

1 Like
(Janmajay Adhikari) #3

@DanielBeckett
Hi Daniel,
Thanks for the suggestion I’m doing the same for second problem. It seems to work at the moment but I’m facing an issue which might not be related to FlowXo,

Whenever I’m trying to hit the API.AI api’s in return I get only the static responses defined in the intent and the webhook mapped to intent doesn’t get triggered.

In case you guys have implemented a similar case while developing or testing will you be able to comment on this?

Thanks,
Jay

(Daniel Beckett) #4

@Janmajay

Hi Jay,

Just to clarify, are you saying that your flow works as far as receiving back the intent from API.AI but then a follow-up action for a webhook is not running based on a filter for a returned value from API.AI? If so, do you see the value returned in your interaction? What happens for the failed action in the interaction logs - any errors?

It may be best to email this over to support@flowxo.com so we can troubleshoot a bit more and offer extra advice.

Thanks,
Dan

(Janmajay Adhikari) #5

Hi Daniel,
Let me explain you the issue. Sorry for not being elaborative earlier.

USE CASE : Weather agent is created in API.AI, I want to fetch NLP responses from API.AI to my web bot for weather forecast.

IMPORTANT : One of the Intents in my weather agent in API.AI has a WEBHOOK that calls weather api and gets the response as weather forecast for a particular city.

EXPECTED : When I use API.AI console the response from weather agent is as expected. Its is able to direct USER QUERY to correct intent and able to execute the webhook (enabled in intent) to get the desired response.Below is the screenshot.

PROBLEM : When I do the same through my Web Bot I get only static responses defined in my Intent. I’m using Rest api and request JSON as below.

REST API : https://api.api.ai/v1/query
REQUEST JSON : {
“query”: [
“{{catchall.message}}”
],
“lang”: “en”,
“sessionId”: “{{catchall.user_id}}”
}

The response that I get from API.ai in above case is as below.

Why the webhook mapped to intent in weather agent doesn’t get triggered when same User Query is sent through web bot.

Thanks,
Jay

(Daniel Beckett) #6

Thanks for the info Jay.

I also see that you’ve emailed this into the support team - I’ll pickup the troubleshooting from there. :slight_smile:

Thanks,
Dan