Skip to content

Instantly share code, notes, and snippets.

@ravpacheco
Created October 3, 2017 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravpacheco/da6f24c361fb38fab5cba9156b352cca to your computer and use it in GitHub Desktop.
Save ravpacheco/da6f24c361fb38fab5cba9156b352cca to your computer and use it in GitHub Desktop.
var stateDocument = await _bucketExtension.GetAsync<JsonDocument>(message.From);
if (stateDocument == null || stateDocument["state"].Equals("S1"))
{
if (text.Equals("S"))
{
var quickReply = new Select
{
Text = "Responda qual é a sua nota para a pesquisa:",
Options = new SelectOption[]
{
new SelectOption{
Text = "1",
Value = "N1"
},
new SelectOption{
Text = "2",
Value = "N2"
},
new SelectOption{
Text = "3",
Value = "N3"
},
},
Scope = SelectScope.Immediate
};
await _sender.SendMessageAsync(quickReply, message.From, cancellationToken);
var session = new JsonDocument();
session["state"] = "P";
await _bucketExtension.SetAsync<JsonDocument>(message.From, session);
}
else
{
var menuDocument = new Select
{
Text = "Olá, tudo bem ? Deseja participar da nossa pesquisa ?",
Options = new SelectOption[]
{
new SelectOption{
Text = "Sim",
Value = "S"
},
new SelectOption{
Text = "Não",
Value = "N"
},
}
};
var session = new JsonDocument();
session["state"] = "S1";
await _bucketExtension.SetAsync<JsonDocument>(message.From, session);
await _sender.SendMessageAsync(menuDocument, message.From, cancellationToken);
}
}
else if (stateDocument["state"].Equals("P"))
{
await _eventTrackExtension.AddAsync("resposta", text);
var resource = new Resource
{
Key = "thanks"
};
await _sender.SendMessageAsync(resource, message.From);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment