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

Rewrite greeting activity trigger in order to work with web chat and directline #1780

Closed
eduardmartos opened this issue Dec 17, 2019 · 2 comments
Assignees
Labels
R8 Release 8 - March 16th, 2020

Comments

@eduardmartos
Copy link

Is your feature request related to a problem? Please describe.
We found that if we use a bot created using Bot Framework Composer in Web Chat control using DirectLine channel, the greeting is displayed twice. The second time is after user sends first message to the bot. The reason is clear, is related to the double event OnConversationUpdateActivity that is fired when the conversation between bot and user starts, the first when bot is added to conversation and the second when is added the user.
We know that it is a "knowed problem" on BotFramework with directline that is solved in most of templates with this two lines of code:
foreach (var member in membersAdded)
if (member.Id != turnContext.Activity.Recipient.Id)

Describe the solution you'd like
I'd like that Bot Framework Composer editor Greeting works by default like in DialogAndWelcome Bot example of Bot Framework SDK 4.

Describe alternatives you've considered
Our first try was to use a distinct value on:
OnConversationUpdateActivity.condition
toLower(turn.Activity.membersAdded[0].name) != 'bot'
->
substring(toLower(turn.Activity.membersAdded[0].name), 0, 3) != 'bot'

Because we detect that name is not always "bot" in our case was "bot-xxxx..."
But it seems that condition on OnConversationUpdateActivity is not really working: we print the condition on message to user and it send 'True' and 'False' but is showing twice.

We found a workarround following this steps:

· blank trigger OnConversationUpdateActivity condition (because is not working)
· adding "Loop: for each item" with itemsProperty = turn.Activity.membersAdded
· adding a "Branch: if/else" with condition = string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)
· Send welcome message only if condition is True
  {
      "$type": "Microsoft.OnConversationUpdateActivity",
      "$designer": {
        "id": "376720"
      },
      "actions": [
        {
          "$type": "Microsoft.Foreach",
          "$designer": {
            "id": "887482",
            "name": "Loop: for each item"
          },
          "itemsProperty": "turn.Activity.membersAdded",
          "actions": [
            {
              "$type": "Microsoft.IfCondition",
              "$designer": {
                "id": "129743",
                "name": "Branch: if/else"
              },
              "condition": "string(dialog.foreach.value.id) != string(turn.Activity.Recipient.id)",
              "actions": [
                {
                  "$type": "Microsoft.SendActivity",
                  "$designer": {
                    "id": "789374",
                    "name": "Send a response"
                  },
                  "activity": "- Welcome, I'm Bot Composer!"
                }
              ]
            }
          ]
        }
      ]
    }

This workarround fixes the bug and we think is the equivalent to Bot Framework standard Welcome Bot:
foreach (var member in membersAdded)
if (member.Id != turnContext.Activity.Recipient.Id)

· We use IDs instead of Names.
· Foreach is better than single condition, because we thinks this will work on other channels with more than user at conversation with the bot like in Teams.

Additional context

@eduardmartos eduardmartos added the Needs-triage A new issue that require triage label Dec 17, 2019
@vishwacsena
Copy link
Contributor

Same as #1632

@hibrenda hibrenda added Area: SDK BF SDK issues and removed Area: SDK BF SDK issues labels Dec 18, 2019
@hibrenda hibrenda added R8 Release 8 - March 16th, 2020 and removed Needs-triage A new issue that require triage labels Dec 19, 2019
@cwhitten
Copy link
Member

addressed in #1794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R8 Release 8 - March 16th, 2020
Projects
None yet
Development

No branches or pull requests

5 participants