Skip to content

Instantly share code, notes, and snippets.

@dhinag
Last active March 28, 2020 14:23
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 dhinag/b47623970e4026b7eb47f3d011cadb99 to your computer and use it in GitHub Desktop.
Save dhinag/b47623970e4026b7eb47f3d011cadb99 to your computer and use it in GitHub Desktop.
//This action is called by the Power Automate
[HttpPost]
[Route("postReview")]
public async Task<IActionResult> PostReview(string activityId, string botId, string conversationId, string serviceUrl, string userId, string channelId, string botName)
{
var convRef = new ConversationReference();
//Revive the conversation reference
convRef.ActivityId = activityId;
convRef.Bot = new ChannelAccount { Id = botId, Name = botName };
convRef.ChannelId = channelId;
convRef.Conversation = new ConversationAccount { Id = conversationId };
convRef.ServiceUrl = serviceUrl;
convRef.User = new ChannelAccount { Id = userId };
//Send the message to the customer using the Conversation Reference
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, convRef, BotCalbackPostReview, default(CancellationToken));
// Let the caller know proactive messages have been sent
return new ContentResult()
{
Content = "<html><body><h1>Proactive messages have been sent.</h1></body></html>",
ContentType = "text/html",
StatusCode = (int)HttpStatusCode.OK,
};
}
private async Task BotCalbackPostReview(ITurnContext turnContext, CancellationToken cancellationToken)
{
var reply = MessageFactory.Text("Would you like to share your experience?");
//Providing a few suggested actions to choreograph the customer's move.
reply.SuggestedActions = new SuggestedActions()
{
Actions = new List<CardAction>()
{
new CardAction() { Title = "Review Experience", Type = ActionTypes.ImBack, Value = "I'd like to review my experience" },
new CardAction() { Title = "I'll do it later", Type = ActionTypes.ImBack, Value = "I'll do it later" },
},
};
await turnContext.SendActivityAsync(reply, cancellationToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment