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

Backchannel: Proactive welcome activity #1445

Closed
robbiew opened this issue Dec 5, 2018 · 7 comments
Closed

Backchannel: Proactive welcome activity #1445

robbiew opened this issue Dec 5, 2018 · 7 comments
Labels
front-burner Sample Implement PoC or sample code

Comments

@robbiew
Copy link

robbiew commented Dec 5, 2018

Having trouble finding any code examples in the repo for Backchannel usage, specifically around using postactivity -- triggering events (I'm using ReactWebChat).

The goal is to trigger a pro-active message via Backchannel to the user as a welcome (using Directline).

This may be sames as #1441

Do any such examples exist? Thanks!

@sgellock sgellock added backlog Out of scope for the current iteration but it will be evaluated in a future release. front-burner labels Dec 5, 2018
@compulim
Copy link
Contributor

compulim commented Dec 5, 2018

@robbiew can you check this PR #1286?

We are still drafting this. Since it touch pretty much every saga (a.k.a. business logic) on the production code, it's pending a thorough test.

The reason we need a production code change is to make the sample simpler and more intuitive. You can look at the proposed sample here.

const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
  if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
    dispatch({
      type: 'WEB_CHAT/SEND_EVENT',
      payload: {
        name: 'webchat/join',
        value: { language: window.navigator.language }
      }
    });
  }
  return next(action);
});

Expect it to drop as dev build around end of December. Production build around mid February (or earlier if we decided to release a point release.)

@compulim compulim changed the title Backchannel js samples? Backchannel: Proactive welcome activity Dec 5, 2018
@compulim compulim added the Sample Implement PoC or sample code label Dec 5, 2018
@dividor
Copy link

dividor commented Dec 7, 2018

Hi @compulim,

I am testing the above code, and though the event seems to be fired, I see nothing on the bot.

Using dev <script src="https://cdn.botframework.com/botframework-webchat/master/webchat.js"></script> ...

And this client code ...

                      (async function () {
                            const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
                            if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
                                console.log("Sending activity ...")
                                dispatch({
                                type: 'WEB_CHAT/SEND_EVENT',
                                payload: {
                                    name: 'webchat/join',
                                    value: { language: window.navigator.language }
                                }
                                });
                            }
                            return next(action);
                            });
                            window.WebChat.renderWebChat({
                                userID: params['userid'],
                                directLine: window.WebChat.createDirectLine({ 
                                    token: params['directLineToken'] 
                                }),
                                store
                            }, document.getElementById('botChat'));
                            document.querySelector('#botChat > *').focus();
                        })().catch(err => console.error(err));

Browser console shows "Sending activity ...", but nothing arrives at the bot as far as I can tell, where my bot is defined ...

// Listen for incoming activities and route them to your bot main dialog.
server.post('/api/messages', (req, res) => {
    // Route received a request to adapter for processing
    adapter.processActivity(req, res, async (turnContext) => {
        // route to bot activity handler.
        await bot.onTurn(turnContext);
    });
});

And ....

async onTurn(turnContext) {

        console.log("STUFF2: " + JSON.stringify(turnContext))
}

Is there something I'm doing wrong please?
thanks,
Matt

@peterswimm
Copy link

We are seeing the same problem - any updates on a fix?

@peterswimm
Copy link

@compulim Looks like we missed the dec projection is there a revised estimate?

@droidriz
Copy link

droidriz commented Jan 9, 2019

passing parameters with v3 was so easy.....
need help with v4 :(

@nrobert
Copy link

nrobert commented Jan 15, 2019

Looks like the latest PR on this subject, completed with a sample, will help you:

Enjoy!

@compulim
Copy link
Contributor

Thanks @nrobert.

Yea, running back-and-forth multiple times on the code and finally it is in! Now in development branch, @4.2.1-master.849e563.

The reason it took so long is because we revamped most sagas. We didn't notice that take(A) -> put -> take(A) -> put -> (loop), is not an atomic operation. In this pattern, we will miss some A actions. Instead, we need to do takeEvery(A, put) -> (loop) instead.

It is in, tell me what you think about it. 😄

@corinagum corinagum removed backlog Out of scope for the current iteration but it will be evaluated in a future release. needs-repro Waiting for repro or investigation labels Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-burner Sample Implement PoC or sample code
Projects
None yet
Development

No branches or pull requests

8 participants