2017-04-18 4 views
0

사용자 쿼리에 응답하는 API.AI 기반 웹 페이지의 예가 있으며 학습 내용을 파악하고 응답을 개선합니다. 나는 웹을 수색했으나 찾지 못했습니다. 아마도 뭔가를 놓친 것 같습니다.API.AI - 웹 페이지 기반 예제

답변

0

OK- 당신은 내가이 질문에 체크 아웃 권하고 싶습니다 (오히려 예를 들어 페이스 북 메신저에 비해) 사용자 정의 웹 기반 응용 프로그램에 API.ai의 chatbot를 배포하는 방법을 찾고 있다면 : how to connect my chatbot user interface to APIAI serverhost via python sdk or javascript?

I을 대부분의 세부 사항을 철자하고 완전한 작동 예제에 연결되었습니다. 그것은 당신을 시작해야합니다.

+0

채팅 봇은 웹 응용 프로그램에 통합 된 두 번째 경우, 하나는 브라우저에서 채팅 할 수 있습니다. – Tweak

0

웹 페이지에 이미 API.AI를 사용하여 생성 한 채팅 봇을 간단하게 퍼가려면 간단합니다. API.AI 작업 공간에서 봇을 게시해야하며 소스 코드를 복사하여 HTML에 붙여 넣으십시오. 이것은 사용자 정의 할 수있는 흰색 레이블 대화 상자가 아니며 단순히 iFrame 내에 있습니다. 또한 서식 지정 (예 : 클릭 가능한 하이퍼 링크를 가질 수 없음) 및 기타 서식있는 텍스트와 관련하여 몇 가지 제한 사항이 있습니다.

자세한 내용은 내 블로그에서이 기사를 참조하십시오.

:

http://miningbusinessdata.com/embedding-api-ai-chatbot-into-your-wordpress-site/

또한 내 자신의 워드 프레스 블로그

http://miningbusinessdata.com/botfolio/

업데이트 04/28/17에 포함 몇몇 (단순한) chatbot이의 몇 가지 예를 볼 수 있습니다

이 작업을 수행하는 데 사용자 지정 코드를 작성하는 방법을 알아 냈습니다. 당신은 이것에 대해 내 기사를 확인할 수 있습니다 https://miningbusinessdata.com/adding-faq-chatbot-to-your-wordpress-site-using-api-ai/

0
Insert your access Token and enjoy! 
    <html> 
    <head> 
     <title>BOT </title> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
     <script type="text/javascript"> 
      var accessToken = "yourAccessToken"; 
      var baseUrl = "https://api.api.ai/v1/"; 
      var synth ; 
      $(document).ready(function() { 
       $("#input").keypress(function(event) { 
        if (event.which == 13) { 
         event.preventDefault(); 
         send(); 
        } 
       }); 
       $("#rec").click(function(event) { 
        switchRecognition(); 
       }); 
      }); 
      var recognition; 
      function startRecognition() { 
       recognition = new webkitSpeechRecognition(); 
       recognition.onstart = function(event) { 
        updateRec(); 
       }; 
       recognition.onresult = function(event) { 
        var text = ""; 
        for (var i = event.resultIndex; i < event.results.length; ++i) { 
         text += event.results[i][0].transcript; 
        } 
        setInput(text); 
        stopRecognition(); 
       }; 
       recognition.onend = function() { 
        stopRecognition(); 
       }; 
       recognition.lang = "en-US"; 
       recognition.start(); 
      } 

      function stopRecognition() { 
       if (recognition) { 
        recognition.stop(); 
        recognition = null; 
       } 
       updateRec(); 
      } 
      function switchRecognition() { 
       if (recognition) { 
        stopRecognition(); 
       } else { 
        startRecognition(); 
       } 
      } 
      function setInput(text) { 
       $("#input").val(text); 
       send(); 
      } 
      function updateRec() { 
       $("#rec").text(recognition ? "Stop" : "Speak"); 
      } 
      function send() { 
       var text = $("#input").val(); 
       $.ajax({ 
        type: "POST", 
        url: baseUrl + "query?v=20150910", 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        headers: { 
         "Authorization": "Bearer " + accessToken 
        }, 
        data: JSON.stringify({ query: text, lang: "en", sessionId: "somerandomthing" }), 
        success: function(data) { 
         setResponse(JSON.stringify(data, undefined, 2)); 
        }, 
        error: function() { 
         setResponse("Errore di comunicazione con il server."); 
        } 
       }); 
       setResponse("Caricamento..."); 
      } 
      function setResponse(val) { 
      //$("#response").text(val); 
      var obj = JSON.parse(val); 
      var response = obj.result.fulfillment.messages[0].speech;//testo a capo //obj.result.fulfillment.speech; 
      if (response != null) 
       $("#response").text(response); 
       else 
       $("#response").text(val); 


      } 
     </script> 
     <style type="text/css"> 
      body { width: 500px; margin: 0 auto; text-align: center; margin-top: 20px; } 
      div { position: absolute; } 
      input { width: 400px; } 
      button { width: 50px; } 
      textarea { width: 100%; } 
     </style> 
    </head> 
    <body> 
     <div> 
      <input id="input" type="text"> <button id="rec">Speak</button> 
      <br>Response<br> <textarea id="response" cols="40" rows="20"></textarea> 
     </div> 
    </body> 
    </html>