durgaprasad rapolu

durgaprasad rapolu

  • 1.8k
  • 57
  • 1.9k

Chat bot reply with face book username

Nov 14 2018 12:18 AM

I have created a chatbot using Visual studio (c#) and Microsoft azure account. It replies well without error.

Now I want to my chatbot reply to display with the facebook username as the first default message.

It is also Ok .
 But it is Repeatedly comming(FbUsername) for any question. It means I am sending Hi to   my bot it will respond  "Hi Durgaprasad"  . again i am sending what is chat bot then my bot  is Hi Durgaprasad and answer that question. 
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
if (activity.Type == ActivityTypes.Message)
string userName = "";
if (activity.From.Name != null)
userName = activity.From.Name;
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity reply = activity.CreateReply("hello" + userName);
activity.TextFormat = "GreetingIntent";
await connector.Conversations.ReplyToActivityAsync(reply);
await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
 But i want to users sending Hi or Hello then only it will come 
 How to do this