0
votes

I need to send a specific user ID from the bot emulator (https://github.com/microsoft/BotFramework-Emulator). I use this textbox (see on a picture below)

enter image description here

But nothing sent. There is absolutely another guid in activity.From.Id.

Is it possible to sent message from emulator with a specific user ID?

1
Are you running your bot purely locally? Or, are you connecting to direct line using a secret or token (and which)? - Steven Kanberg

1 Answers

0
votes

The short answer is, if you are using Direct Line to generate a token from a secret and you specify user Id there (see attached code), then Emulator should favor that value over any value you pass in thru the Emulator settings.

In my personal testing, the User ID setting seems to be overriding any other pre-existing value.

It should be noted, however, that if you specify a User ID value in settings, you will need to close the tabbed conversation and start it anew by re-entering the messaging endpoint and AppId/AppPassword (or reconnecting to your .bot file, if used). Simply pressing "Restart conversation" will not cause Emulator to pickup the User ID setting.

Hope of help!

// Listen for incoming requests.
server.post('/directline/token', (req, res) => {
  // userId must start with `dl_` for Direct Line enhanced authentication
  const userId = (req.body && req.body.id) ? req.body.id : `dl_${ Date.now() + Math.random().toString(36) }`;
  const options = {
    method: 'POST',
    uri: 'https://directline.botframework.com/v3/directline/tokens/generate',
    headers: {
      'Authorization': `Bearer ${ process.env.directLineSecret }`
    },
    json: {
      user: {
        Id: `${ userId }`
      }
    }
  };
  request.post(options, (error, response, body) => {
    if (!error && response.statusCode < 300) {
      res.send(body);
      console.log('Someone requested a token...');
    } else {
      res.status(500).send('Call to retrieve token from DirectLine failed');
    }
  });
});

enter image description here

enter image description here