MS Bot framework emulator chang user id

Viewed 2209

Is there a way to change the default user id (which is 'default-user') in bot emulator?

Or maybe it supports something about multi conversations in the same time?

I want to emulate two different users at the same time (because I have multiple user types in my project.

When I try to create new conversation like this

....
var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
var userAccount = new ChannelAccount("//here we need to provide user id which is always default-user", "Provider");
var botAccount = context.Activity.Recipient;

var conversation = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
var message = context.MakeMessage();
message.Recipient = userAccount;
message.From = botAccount;
message.Conversation = new ConversationAccount(false, conversation.Id);
await connector.Conversations.SendToConversationAsync((Activity) message);

My emulator opens new conversation in the same chat-window

4 Answers

I work on the Bot Framework Emulator. We've recently added the ability to override generated user ids to be used in conversations without the need of a tool like Fiddler. You can utilize this feature in our latest release. I hope you find this useful for your scenario.

I don't know a way of having multiple conversations with different users, but you cant change the id/name of the user that is currently sending messages.

You can do this by editing the config file that the emulator uses to store its settings.

On linux I found this settings file here: ~/.config/botframework-emulator/botframework-emulator/server.json

You'll find a section "users" in that json file.

Change that section to:

"users": {
    "currentUserId": "default-user2",
    "usersById": {
      "default-user": {
        "id": "default-user",
        "name": "User"
      },
      "default-user2": {
        "id": "default-user2",
        "name": "User2"
      }
    }

You'll need to restart the emulator and then your conversation should be with User2 now instead of User.

When you want to change it back you just need to change:

"currentUserId": "default-user2",

back to

"currentUserId": "default-user",
Related