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

How to receive error message from the Bot on Timeout #1630

Closed
ljubomirsinadinovski opened this issue Jan 23, 2019 · 5 comments
Closed

How to receive error message from the Bot on Timeout #1630

ljubomirsinadinovski opened this issue Jan 23, 2019 · 5 comments
Labels
question Further information is requested. Stack Overflow candidate

Comments

@ljubomirsinadinovski
Copy link

ljubomirsinadinovski commented Jan 23, 2019

In this scenario we have failed to send our message and I want to reply (in the chat, as it is written by the bot). I can't find any action to dispatch in order to receive a message from the bot. If I call SEND_MESSAGE_BACK action i end up sending more messages instead of receiving. You can reproduce this if you connect to the chat and then turn off the Internet from you PC/Browser.

this.chatStore = createStore(
      onErrorResumeNext(() => {
        const reduxStore = window.localStorage.getItem(REDUX_CHAT_STORE_KEY) ? window.localStorage.getItem(REDUX_CHAT_STORE_KEY) : "{}";
        return JSON.parse(reduxStore as string);
      }),
      ({ dispatch }: any) => (next: any) => (action: any) => {
        if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
          dispatch({
            type: 'WEB_CHAT/SEND_EVENT',
            payload: {
              name: 'webchat/join',
              value: { language: window.navigator.language },
              type: 'event',
              from: { id: this.id },
            }
          });
        } else if (action.type === 'DIRECT_LINE/POST_ACTIVITY_REJECTED') {
          console.log("enters required reducer")
          // dispatch({
          //   type: '', //WHAT ACTION SHOULD I DISPATCH IN ORDER TO RECEIVE MESSAGE????
          //   payload: {
          //     displayText: 'dont care',
          //     text: 'hahahah',
          //     value: "whatever"
          //   }
          // })
        }
        return next(action);
      }
    );
@corinagum
Copy link
Contributor

@ljubomirsinadinovski I'm sorry, I'm having trouble understanding your request. Could you clarify? What I understand is that you are trying to alert the bot USER that sending a message to the BOT has failed. You want this message to come from the bot. Is this correct? This is not a feature of Web Chat.

We have some enhancement work items #135 related to Offline UI display, but this would not be a message from the bot. Is this similar to what you are looking for?

@corinagum corinagum added Pending question Further information is requested. Stack Overflow candidate labels Jan 23, 2019
@ljubomirsinadinovski
Copy link
Author

ljubomirsinadinovski commented Jan 23, 2019

@ljubomirsinadinovski I'm sorry, I'm having trouble understanding your request. Could you clarify? What I understand is that you are trying to alert the bot USER that sending a message to the BOT has failed. You want this message to come from the bot. Is this correct? This is not a feature of Web Chat.

We have some enhancement work items #135 related to Offline UI display, but this would not be a message from the bot. Is this similar to what you are looking for?

Yes you understood right. I am going to write the scenario in order to clarify better:

  • User: Hello chat bot, give me some help (this request fails and activates DIRECT_LINE/POST_ACTIVITY_REJECTED)
  • Bot: I am sorry, I am not available at the moment, please try again in couple of minutes (this is the message response action that I am looking for that comes from the bot)

I think that the Web Chat should include this type of action, because it is really important to make the Web Chat as user friendly as possible. Also would help developers to add custom things without contacting the directLine/back-end

BTW: The reducer I call above (with action type DIRECT_LINE/POST_ACTIVITY_REJECTED) covers the case when the message send is failing... that is the very reason why I want to return general error message that looks like its coming from the bot (but actually isn't)

@corinagum
Copy link
Contributor

Thanks for the clarification. It sounds like the features you are looking for are similar to the Offline UI issues that are already filed and in the works. The only difference is that these messages will show above the Sendbox, within the transcript as a notification, not an activity from the bot. One of the problems of making the message appear to come from the bot is that because there are connectivity issues, you are not necessarily connected to the bot for it to receive or send activities.

As an example, #1521 is the issue that will display a message when connecting to the bot is slow or has errors. The front-end waits for a connection from the bot, and displays a warning or error if no data comes from the bot. The feature will not look like a message from the bot, however.

One solution I can see for you is to modify our component (once the feature is released) with styleOptions to appear like a chat bubble. @compulim, @cwhitten, should we preemptively create mod-ability for Offline UI to support this scenario?

@compulim
Copy link
Contributor

compulim commented Jan 24, 2019

@ljubomirsinadinovski I think in this case, there are few options for now:

  • Wait for @corinagum work on offline UI, targetting mid-Feb release (there are some mock ups in Need offline UI: Connection is taking longer than usual #1521)
  • You can mock an incoming message by dispatching DIRECT_LINE/INCOMING_ACTIVITY. I won't recommend this approach because anything DIRECT_LINE/* could change from time to time. But at the very least, you know this is Redux, and anything that change the store must be triggered by an action. If we change this action, there must be another action to replace it
  • Look at reducer/activities.js, and add an artificial activity when you get WEB_CHAT/DISCONNECT_PENDING (or some other actions). I didn't take a deep thought on this, but I think this might work

What do you think?

@ljubomirsinadinovski
Copy link
Author

Cheers, thank you @compulim and @corinagum! I guess I am going to wait for the mid-Feb release, that works for me. I won't play around with DIRECT_LINE/* actions as suggested, I agree. I won't take into consideration the 3rd approach because if technical debt that may arose, as well as maintenance. I am going to close this issue now, because we have come to a conclusion ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested. Stack Overflow candidate
Projects
None yet
Development

No branches or pull requests

3 participants