9 Replies Latest reply: Jan 13, 2018 12:00 AM by Amol Rane RSS

    qliknetbot: getting links as a string or plain text

    Amol Rane

      I am working on netbot posted by Todd Margolis. Whenever I am able to receive a response from the bot but it is giving me plain text or string even if it is a hyperlink. Below is the screenshot of the response.Capture3.PNG

      I am using Telegram Bot. The highlighted area should appear as a link not, as a text.

        • Re: qliknetbot: getting links as a string or plain text

          i have the same problem

          i think, it happen because of the URL is too long.

          i use a google Google URL Shortener and it works fine.

           

          and of course you have to change massage prase type to HTML

          • Re: qliknetbot: getting links as a string or plain text
            Amol Rane

            Hi, @Damith Thiwanka thanks for your reply. Since I am new to c# if you could help me with the implementation that would be a great help. Thanks in advance.

            • Re: qliknetbot: getting links as a string or plain text
              Amol Rane

              private const string key = " dfaga5346sdfgfhsh"; #My api key

                      public string urlShorter(string url)  #this function takes url to shortened as a parameter.

                      {

                          string finalURL = "";

                          string post = "{\"longUrl\": \"" + url + "\"}";

                          string shortUrl = url;

                          HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + key);

                          try

                          {

                              request.ServicePoint.Expect100Continue = false;

                              request.Method = "POST";

                              request.ContentLength = post.Length;

                              request.ContentType = "application/json";

                              request.Headers.Add("Cache-Control", "no-cache");

                              using (Stream requestStream = request.GetRequestStream())

                              {

                                  byte[] postBuffer = Encoding.ASCII.GetBytes(post);

                                  requestStream.Write(postBuffer, 0, postBuffer.Length);

                              }

                              using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

                              {

                                  using (Stream responseStream = response.GetResponseStream())

                                  {

                                      using (StreamReader responseReader = new StreamReader(responseStream))

                                      {

               

                                          string json = responseReader.ReadToEnd();

                                          dynamic data = JObject.Parse(json);

                                          finalURL = data;

               

                                      }

                                  }

                              }

                          }

                          catch (Exception ex)

                          {

                              // if Google's URL Shortener is down...

                              System.Diagnostics.Debug.WriteLine(ex.Message);

                              System.Diagnostics.Debug.WriteLine(ex.StackTrace);

                          }

                          return finalURL;

                      }

              But this is not working. Help me to fix this.

              • Re: qliknetbot: getting links as a string or plain text
                Sachin Gupta

                Can you verify if the expected Url is correct or not?

                 

                If the Url is empty or not a valid Url, if will display as text.

                • Re: qliknetbot: getting links as a string or plain text
                  Rajat Menon

                  Hi Amol,

                   

                  Have you implemented the bot for qlik sense i need your help in doing so, getting error connection failed after 4 attempts for qlik bot node and app id not found for .net sdk bot.