0
votes

I'm using webchat to make make a simple web interface for my bot. My bot has authentication using BotAuth to connect to an Azure Active Directory. When I log in it works fine but when I start a new converstation on another device it contiues my conversation when it should be a new clean conversation.

I used this https://github.com/Microsoft/BotFramework-WebChat but I doesn't work

 $.ajax({
            type: "POST",
            headers: {
                "Authorization": "Bearer " + "yupOGxl-odA.cwA.USk.zul_EXUwk54fWqKT_N8hmsWyXSWo5DHMYj0r7DQjaZI"
            },
            url: "https://directline.botframework.com/v3/directline/tokens/generate",
        }).done(function (response) {
            console.log(response)
            BotChat.App({
                directLine: {
                    token: response.token
                },
                user: { id: 'userid' },
                bot: { id: 'botid' },
                resize: 'detect'
            }, document.getElementById("bot"));
        });
1
Most people would argue the opposite that they would want the same user to have the same conversations across all devices. What are you trying to accomplish here? What is your goal? Why do you want a new conversation based off device?D4RKCIDE
I have 2 users in my bot and somehow when I use it I'm logged in as the other personsamvanlier
you are giving every user the same ID user: { id: 'userid' },D4RKCIDE

1 Answers

2
votes

when I start a new converstation on another device it contiues my conversation when it should be a new clean conversation.

It seems that you’d like to generate and pass a Direct Line Token to initiate BotChat. In this section: “Secrets and tokens”, you can find "A Direct Line token is a key that can be used to access a single conversation".

If you generate a new token via Ajax request and use it to initiate BotChat every time when new user logged in, a new conversation should be started with that token, you can use browser network tool to check the conversationId in response of starting a conversation.

On the other hand, if you use same Direct Line Token on another device/browser client(or tab), it will access the same conversation.

I have 2 users in my bot and somehow when I use it I'm logged in as the other person

As JasonSowers mentioned in his comment, you are specifying same userid when you initiate BotChat, you had better to get current logged-in user’s id and dynamically pass it to BotChat user property.

Note: In your code, you make ajax request for generating token based on your Direct Line Secret on JavaScript client side, which still expose the Direct Line Secret. Others can easily get your Direct Line Secret by checking your JavaScript code then put your bot on their website. If possible, you can create a backend service and put the code logic for generating token on server-side, which would help hide your secret from client side.