Open stefanzweifel opened 6 years ago
I'm seeing the same issue, only the first response comes through
I noticed this too. It's not a huge deal unless you're dealing with really long responses (like lists, which I am tinkering with). Chat has a limit of ~4000 chars to a message, and silently fails if you send a message that's too long, so in my case I figured using Laravel's chunk()
method would do the trick - chunk the result and send multiple messages.
Well then I noticed this issue, and so I had to break it down further - I ended up implementing a sort of "pagination", where I store the chunks in user storage, and then the user types next
to retrieve the next chunk. It's not pretty, but... it works.
I'd love to see this Driver get some updates. If our use case takes off, I might see what I can do...
I'm digging deeper into this and have noticed the same thing that @stefanzweifel did - the payloads are being sent properly. It seems that the issue could be on the Google Chat end... potentially with their synchronous vs. asynchronous response methodology: https://developers.google.com/hangouts/chat/how-tos/bots-develop#syncresponse
I shoved a sleep(10)
into the sendPayload()
method on this driver to see what would happen, and sent two replies from a test endpoint. I noticed that I ended up with no response in Google Chat at all, until after both requests had been sent.
So my guess is that Google is basically just swallowing up the second one somehow. I'm going to see what I can do to keep digging on this.
Edit - looking here: https://developers.google.com/hangouts/chat/concepts/structure?hl=en_US seems to confirm that I'm on the right track. Re: synchronous:
In this pattern, the bot responds to messages from users on a one-to-one basis. One user message to the bot results in one response from the bot.
Asynchronous responses would need to be implemented in order to send multiple replies back... for that you would need to look into using service accounts, and implement some sort of thread tracking. I don't think this driver is wired for service accounts, so I think any progress here would have to take that under consideration.
Hey there 👋,
I have an issue while sending multiple replies with the Hangouts driver: Only the first appears, the others are not visible in the chat. My bot should send the different menus of the canteen into a room or DM. Code looks basically like this:
The Web- and Telegram Driver correctly sends 4 replies:
Web Driver
Telegram Driver
The Hangouts driver however only shows the first reply 🤔:
I've hooked myself into the
sendPayload
method ofBotman
to see, what the Hangouts driver sends to Google, but in my eyes, everything looks fine 🤷♂️ :I know that Hangouts Chat is not the sexiest Chat app but I would really appreciate it if anyone has some ideas, where Botman falls apart here.
If I should provide more code details or other information: I'm happy to provide everything.
Appendix
I could fix my bot by only ever reply once. (But it seems a bit hacky)