Created
October 3, 2017 15:07
-
-
Save ravpacheco/da6f24c361fb38fab5cba9156b352cca to your computer and use it in GitHub Desktop.
This file contains 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
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