public SkillResponse ToSkillResponse(IBotResponse response) { IOutputSpeech outputSpeech; if (response.IsSSML) { outputSpeech = new SsmlOutputSpeech() { Ssml = String.Format("<speak>{0}</speak>", response.Speak ?? String.Empty) }; } else { outputSpeech = new PlainTextOutputSpeech { Text = response.Speak ?? String.Empty }; } SkillResponse nativeResponse = null; if (response.PermissionRequests.HasFlag(PermissionType.Address)) { var permissions = new List <string>(); permissions.Add(_addressOnlySupportsPostalCode ? "read::alexa:device:all:address:country_and_postal_code" : "read::alexa:device:all:address"); nativeResponse = ResponseBuilder.TellWithAskForPermissionConsentCard(response.Speak, permissions, _request.Session); } else if (response.Content != null) { var card = response.Content as ICard; if (card != null) { nativeResponse = ResponseBuilder.TellWithCard(outputSpeech, response.Title ?? String.Empty, JsonConvert.SerializeObject(card), _request.Session); } else { nativeResponse = ResponseBuilder.TellWithCard(outputSpeech, response.Title ?? String.Empty, response.Content.ToString(), _request.Session); } } if (nativeResponse == null) { nativeResponse = ResponseBuilder.Tell(outputSpeech, _request.Session); } nativeResponse.Response.ShouldEndSession = response.ExpectedUserResponse == UserResponse.None ? true : false; return(nativeResponse); }
public async Task SendProgressResponseAsync(IBotResponse response) { var progressiveResponse = new ProgressiveResponse(_request); var speechResponse = await progressiveResponse.SendSpeech(response.Speak); if (speechResponse.IsSuccessStatusCode) { Log("Progress Response successful"); } else { Log("Progress Response unsuccessful"); } }
/// <summary> /// Contruction /// </summary> /// <param name="serverHost">gRPC server</param> /// <param name="listen">Plugin API calls listen addr</param> /// <param name="cookie">Cookie file</param> /// <param name="schema">Login in schema</param> /// <param name="secret">Login in credentials</param> /// <param name="botResponse">Chatbot auto reply implement interface,you can use this to make you own chat logic</param> public ChatBot(string serverHost = "localhost:6061", string listen = "0.0.0.0:40052", string cookie = ".tn-cookie", string schema = "basic", string secret = "", IBotResponse botResponse = null) { //Initial a tid with a random value btw 1~1000 NextTid = new Random().Next(1, 1000); ServerHost = serverHost; Listen = listen; CookieFile = cookie; Schema = schema; Secret = ByteString.CopyFromUtf8(secret); BotResponse = botResponse; cancellationTokenSource = new CancellationTokenSource(); sendMsgQueue = new Queue <ClientMsg>(); subscriptions = new Dictionary <string, bool>(); onCompletion = new Dictionary <string, Future>(); }
public MultipleChoiceDialog WithResponse(IBotResponse botResponse) { this.Responses.Add(botResponse); return(this); }
public void AddResponse(IBotResponse botResponse) { _logger.Info($"Added response {botResponse.GetType()}."); _botResponses.Add(botResponse); }
public FreeTextDialog AddResponse(IBotResponse botResponse) { this.Responses.Add(botResponse); return(this); }
public SurveyStartDialog AddResponse(IBotResponse botResponse) { this.Responses.Add(botResponse); return(this); }
public void AddResponse(IBotResponse botResponse) { logger.LogInformation($"Added response {botResponse.GetType()}."); _botResponses.Add(botResponse); }
public void AddResponse(IBotResponse botResponse) { _botResponses.Add(botResponse); }