Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question buttons do not work in Bot Framework Emulator #19

Open
neilherbertuk opened this issue Oct 9, 2020 · 0 comments · May be fixed by #20
Open

Question buttons do not work in Bot Framework Emulator #19

neilherbertuk opened this issue Oct 9, 2020 · 0 comments · May be fixed by #20

Comments

@neilherbertuk
Copy link

neilherbertuk commented Oct 9, 2020

Setup
I'm using the Botframework Emulator with Botman Studio and the bot framework driver.

Issue

  • Start a new conversation that responds with a question.
  • Click on button to respond.
  • Response isn't parsed with a 500 error.

There appears to be an issue where the HTML tag that is being given to the question buttons as a response is in a different format to what is expected by the driver as a response.

Conversation

You said:
Start conversation
Huh - you woke me up. What do you need?
Tell a joke
Give me a fancy quote
You said:
Tell a joke <botman value="joke" />

Requests

[14:23:16] -> message Start conversation
[14:23:16] POST 200 directline/conversations//activities
[14:23:18]<- message application/vnd.microsoft.card.hero
[14:23:18] POST 200 conversations//activities
[14:23:20]-> message Tell a joke <botman value="joke" />
[14:23:21] POST 500 directline/conversations//activities

Error

ErrorException: Undefined offset: 1 in file /Users/hfh83/Documents/Projects/StatusBot/vendor/botman/driver-botframework/src/BotFrameworkDriver.php on line 60

This is because this regex doesn't match the pattern

BotFrameworkDriver.php

55 preg_match('/<botman value="(.*)"><\/botman>/', $message->getText(), $matches);

The issue is that when the question buttons are generated as part of the convertQuestion method on line 118 of BotFrameworkDriver.php sets the HTML tag used for this to the shorthand ending in /> instead of a separate closing tag that's expected as shown above.

BotFrameworkDriver.php

118 'value' => $button['text'].'<botman value="'.$button['value'].'" />',

The test used to check this has the closing tag as part of the test so the test passes, despite this being incorrect

BotFrameworkDriverTest.php

537  $text = 'I use botman with Skype<botman value="yes"></botman>'

Solution

Change
BotFrameworkDriver.php

55 preg_match('/<botman value="(.*)"><\/botman>/', $message->getText(), $matches);

to
BotFrameworkDriver.php

55 preg_match('/<botman value="(.*)" \/>/', $message->getText(), $matches);

I'll submit a pull request with the changes needed to fix this.

neilherbertuk pushed a commit to neilherbertuk/driver-botframework that referenced this issue Oct 9, 2020
Update BotFrameworkDriver.php to correct regex pattern
Update BotFrameworkDriverTest.php it_interactive_responses_correctly to correct hardcoded format expected
Set version number for mockery/mockery as doesn't support phpunit 5
neilherbertuk added a commit to neilherbertuk/driver-botframework that referenced this issue Oct 12, 2020
Fix issue botman#19, question buttons response in wrong format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant