This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dictionary<string, object> dict = new Dictionary<string, object>(); | |
dict.Add("ticket_id", "this is string"); | |
dict.Add("order", this.order); | |
context.Call(this.dialogFactory.Create<OrderSummaryDialog, Dictionary<string, object>>(dict), this.AfterOrderSummaryDialog); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class RootDialog : IDialog<object> | |
{ | |
private ConversationReference conversationReference; | |
private IDialogFactory dialogFactory; | |
public RootDialog(IDialogFactory dialogFactory) | |
{ | |
this.dialogFactory = dialogFactory; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDialogFactory | |
{ | |
//constructor without dynamic params | |
T Create<T>(); | |
//Constructor requiring multiple dynamic params | |
T Create<T>(IDictionary<string, object> parameters); | |
} | |
public class DialogFactory : IDialogFactory | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// POST: api/Messages | |
/// Receive a message from a user and reply to it | |
/// </summary> | |
public async Task<HttpResponseMessage> Post([FromBody]Activity activity) | |
{ | |
if (activity.Type == ActivityTypes.Message) | |
{ | |
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity)) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// POST: api/Messages | |
/// Receive a message from a user and reply to it | |
/// </summary> | |
public async Task<HttpResponseMessage> Post([FromBody]Activity activity) | |
{ | |
if (activity.Type == ActivityTypes.Message) | |
{ | |
await Conversation.SendAsync(activity, () => new Dialogs.RootDialog()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class RootDialog : IDialog<object> | |
{ | |
private IProfileService profileService; | |
public RootDialog(IProfileService profileService) | |
{ | |
this.profileService = profileService; | |
} | |
//code removed for sanity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyBotModules : Module | |
{ | |
protected override void Load(ContainerBuilder builder) | |
{ | |
base.Load(builder); | |
//Register RootDialog as IDialog<object> | |
builder.RegisterType<RootDialog>() | |
.As<IDialog<object>>() | |
.InstancePerDependency(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In your dialog | |
Activity message = result as Activity; | |
//Create scope with respect to activity | |
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message)) | |
{ | |
//Resolve scope for IBotDataStore<BotData> | |
IBotDataStore<BotData> stateStore = scope.Resolve<IBotDataStore<BotData>>(); | |
/* Retrieve user address. Address key holds information about Bot, Channel, User and conversation */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Address key = Address.FromActivity(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In your dialog | |
Activity message = result as Activity; | |
//Create scope with respect to activity | |
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, message)) | |
{ | |
//Resolve scope for IBotDataStore<BotData> | |
IBotDataStore<BotData> stateStore = scope.Resolve<IBotDataStore<BotData>>(); | |
/* Retrieve user address. Address key holds information about Bot, Channel, User and conversation */ |