Returning JSON result from MYSQL query

(Joel Baxter) #1

Hi there, I was wondering if anyone had any suggestions with what I’m trying to do. I’ve been following along with this tutorial, but I’m running into a roadblock. http://www.chatfuel.ga/2017/08/using-broadcast-api-without-codingserver.html

I’m creating a bot using chatfuel that connects to flow xo using the JSON api.

  1. I have a webhook that receives a food item that someone wants to pair wine with. This step works.

  2. I then have a MYSQL action that connects to a wine pairing database, and gets the top 3 wine choices. This step works as well.

  3. Here’s where I stumble. My next action is an http request that returns the first wine choice (I’d like to return all 3 at some point, but for now 1 would be nice just to get it going) value (under the guise of Chicken_Dinner to flow xo. It uses method POST and Type RAW BODY

Here’s where I’m stuck: What I have currently is

{
“Chicken_Dinner”:{{mysql_query.result__rows__varietal__0}}
}

However I think I have what is in {{ }} completely wrong, as it doesn’t post any output. All I get is:

HTTP Method
POST
Content Type
Raw Body
Body
{
“Chicken_Dinner”:{{mysql_query.result__rows__varietal__0}}
}
Headers
Content-Type: application/json
Close

If someone could help me out. I have the output of a GET HTTP_Request below that might prove useful

HTTP Method
GET
Content Type
JSON
Body
{
“59cec246fb80a7003ba42000”: {
“chatfuel_user_id”: “1649903251747360”,
“food”: “lobster”,
flowxo_task_name”: “Receive a Webhook”
},
“59cec26e57f6ac006d3fbc79”: {
“result”: {
“rows”: [
{
“varietal”: “Chardonnay”
},
{
“varietal”: “Burgundy, White”
},
{
“varietal”: "Champagne, Blanc de blancs "
}
],
“fields”: [
{
“catalog”: “def”,
“db”: “whattop0_wine”,
“table”: “view_wine”,
“orgTable”: “varietal”,
“name”: “varietal”,
“orgName”: “varietal”,
“charsetNr”: 33,
“length”: 900,
“type”: 253,
“flags”: 4097,
“decimals”: 0,
“zeroFill”: false,
“protocol41”: true
}
]
},
flowxo_task_name”: “Run a Query”
}
}

(Daniel Beckett) #2

@13axtula

It looks like it could actually be something like:
{{mysql_query.59cec26e57f6ac006d3fbc79__result__rows__0__varietal}}

Hard to tell sometimes without having the outputs to test with :grin:

If that doesn’t work could you share your flow by emailing support@flowxo.com ?

Thanks,
Dan

(Joel Baxter) #3

Thanks Dan! That didn’t seem to work out so I shared my flow with support@flowxo.com. I totally get needing to see different outputs! Thanks again!