not showing the image showing like this
- using System.Net;
- using System.Net.Http;
- using System.Threading.Tasks;
- using System.Web.Http;
- using Microsoft.Bot.Builder.Dialogs;
- using Microsoft.Bot.Connector;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web.Http.Description;
- //using Microsoft.Bot.Connector.Utilities;
- using Newtonsoft.Json;
- namespace Bot_Application3
- {
- [BotAuthentication]
- public class MessagesController : ApiController
- {
- ///
- /// POST: api/Messages
- /// Receive a message from a user and reply to it
- ///
- public async Task
Post([FromBody]Activity activity) - {
- if (activity.Type == ActivityTypes.Message)
- {
- ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
- int length = (activity.Text ?? string.Empty).Length;
- //Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} character");
- Activity reply = activity.CreateReply("images of lahore garrison university");
- reply.Attachments = new List
(); - reply.Attachments.Add(new Attachment()
- {
- ContentUrl = "http://www.lgu.edu.pk/assets/img/logo.JPG",
- ContentType= "image/jpg",
- Name="LGU.JPG"
- });
- await connector.Conversations.ReplyToActivityAsync(reply);
- }
- else
- {
- HandleSystemMessage(activity);
- }
- var response = Request.CreateResponse(HttpStatusCode.OK);
- return response;
- }
- private Activity HandleSystemMessage(Activity message)
- {
- if (message.Type == ActivityTypes.DeleteUserData)
- {
- // Implement user deletion here
- // If we handle user deletion, return a real message
- }
- else if (message.Type == ActivityTypes.ConversationUpdate)
- {
- // Handle conversation state changes, like members being added and removed
- // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
- // Not available in all channels
- }
- else if (message.Type == ActivityTypes.ContactRelationUpdate)
- {
- // Handle add/remove from contact lists
- // Activity.From + Activity.Action represent what happened
- }
- else if (message.Type == ActivityTypes.Typing)
- {
- // Handle knowing tha the user is typing
- }
- else if (message.Type == ActivityTypes.Ping)
- {
- }
- return null;
- }
- }
- }
Sankara Krishnan VenugopalPosted May 1, 2018, 7:04 AM