botman / botman/driver-hangouts

Issue with Multiple Replies

Open
#3 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
10
Forks
5
PR merge metrics
No merged PRs in 30d

Description

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:

```php
$botman->hears('menu', function ($bot) {

$bot->reply('Looking for menues…');

// Do some API calls to get the menues

$todaysMenus = collect([
['title' => 'Menu 1: Food A'],
['title' => 'Menu 2: Food B'],
['title' => 'Menu 3: Food C']
]);

$todaysMenus->each(function ($menu) use ($bot) {
$bot->reply($menu['title']);
});
});
```

The Web- and Telegram Driver correctly sends 4 replies:

##### Web Driver

![image](https://user-images.githubusercontent.com/1080923/43991860-849d43b6-9d75-11e8-8f23-79f2ed7be1ac.png)

#### Telegram Driver

![image](https://user-images.githubusercontent.com/1080923/43991868-abab4c32-9d75-11e8-8082-e6942ad92677.png)

The Hangouts driver however only shows the first reply 🤔:

![image](https://user-images.githubusercontent.com/1080923/43991880-efce6b2e-9d75-11e8-997f-9822e8df3697.png)

I've hooked myself into the [`sendPayload`](https://github.com/botman/botman/blob/b4d07814c5848fce1e841bba836c7d1a3ee51d29/src/BotMan.php#L633-L640) method of `Botman` to see, what the Hangouts driver sends to Google, but in my eyes, everything looks fine 🤷‍♂️ :

```log
[2018-08-11 12:57:03] local.INFO: array (
'text' => 'Looking for menues 👀',
'cards' =>
array (
0 =>
array (
'sections' =>
array (
0 =>
array (
'widgets' =>
array (
),
),
),
),
),
)
[2018-08-11 12:57:03] local.INFO: array (
'text' => 'Menu 1: Food A',
'cards' =>
array (
0 =>
array (
'sections' =>
array (
0 =>
array (
'widgets' =>
array (
),
),
),
),
),
)
[2018-08-11 12:57:03] local.INFO: array (
'text' => 'Menu 2: Food B',
'cards' =>
array (
0 =>
array (
'sections' =>
array (
0 =>
array (
'widgets' =>
array (
),
),
),
),
),
)
[2018-08-11 12:57:03] local.INFO: array (
'text' => 'Menu 3: Food C',
'cards' =>
array (
0 =>
array (
'sections' =>
array (
0 =>
array (
'widgets' =>
array (
),
),
),
),
),
)
```

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)

```php
$botman->hears('menu', function ($bot) {

// Do some API calls to get the menues

$todaysMenus = collect([
'Menu 1: Food A',
'Menu 2: Food B',
'Menu 3: Food C'
]);

$bot->reply($todaysMenus->implode("\n"));
});
```

Contributor guide

Open the contributing guide

Research direction

Start at src/BotMan.php, especially the sendPayload method linked in the report, and trace how the Hangouts driver handles successive replies. Run the supplied PHP reproduction and compare its four payloads with what appears in Hangouts. Done means all four replies are visible in the Hangouts room or DM, as they are with the Web and Telegram drivers.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.