Bot reading wrong choice from HTTP request

(Daniel Souza Bertoldi) #1

This is going to be a long explanation because what I’m trying to do is somewhat kinda complex, so I’ll try my best to summarize the problem while still being as specific as possible.

Overview

I created an API that reads all the rows in a Google Sheets and returns each row as a choice to the user since the number of events in a given week is unpredictable, here’s an example:

And this is how my API is returning the JSON:

{
    "events": "\n1 - Phil Pallen - 21/07 - 20h\n2 - Transmedia - 22/07 - 20h\n3 - Hello Future 10 - 23/07 - 17h\n4 - Tour na Full Sail - 27/07 - 18h\n5 - Elbert Perez - 28/07 - 20h\n6 - Entretenimento nas Corporações - 29/07 - 20h\n7 - Contact support\n8 - Go back to main menu\n",
    "choices": [
        {
            "choice": 1,
            "value": 0
        },
        {
            "choice": 2,
            "value": 1
        },
        {
           "choice": 3,
            "value": 2
        },
        {
            "choice": 4,
            "value": 3
        },
        {
            "choice": 5,
            "value": 4
        },
        {
            "choice": 6,
            "value": 5
        },
        {
            "choice": 7,
            "value": "support"
        },
        {
            "choice": 8,
            "value": "menu"
        }
    ]
}

The “choice” key inside the “choices” array is the value that’ll be presented to the user, and the “value” key is the value that goes in the “answer” field of the question, like this:

Sometimes, the choice the user makes actually returns the matching event, here’s one case:

- Menu presented to the user

- Choices presented to the user

- User choice

Choice = 1, Answer = 0, that’s correct!

- Live interaction:

But, other times, it doesn’t work at all. It seems like the choice menu is missing one of the options, because if a user chooses, mirroring the previous example, the event number 1, it actually gets interpreted as event number 2. Here’s what I mean:

(Both have the same menu and choices showed above, so there’s no need to screenshot them again)

- User choice

Wrong! As it can be seen from the screenshot below, the user actually chose the first event, not the second

- Live interaction

image

I put the timestamp, which is 3 hours behind the timestamp from the FlowXO site since I’m in Brazil, so that I can prove is the same interaction.

I honestly have no ideia why this is happening, and I’d be very grateful for any help in this matter. It’s like a hit or miss situation, 50/50 chance of the bot getting it right or wrong (the chances of getting it wrong are higher in the Messenger version of the bot).

I am willing to provide more information if needed, and to change my solution to this particular problem if it means not having this problem at all.

And yes, I translated much of the texts so it could be easier to understand :slight_smile:

(Nathan Stults) #2

Daniel, thanks for the detailed explanation. For us to troubleshoot, we’ll need you to share your flow and also link us to working/non-working request IDs so we can look into our logs and see what might be going wrong. You won’t want to post that in public though, so could you open a ticket with us at support@flowxo.com and we can take it from there?

(Daniel Souza Bertoldi) #3

Hey @nathan, sorry for disappearing. I actually managed to solve it by removing all the values in the ‘answer’ field and just checking the choices. To make this work, I also had to change my API so that it also returns the menu/go back options value.

I’m still clueless as to why that was happening. Now I don’t know if I should open a ticket at all, since I kinda fixed it hahahaha