Skip to Content
Author's profile photo Othmane NGABI

Building ChatBot using SAP Cloud Platform – Part 2

Previous article Here Next article Here    

 

Building ChatBot


I will use DialogFlow ChatBot for my implementation. Go to https://dialogflow.com/ Sign up for free ( as a Google product you can use your Google Account to sign in ).

ChatBot Framework in general is well documentated you can find a lot of topics talking about this with easy effort.

Some interesting links :

Wikipedia definition

http://www.digitalistmag.com/digital-economy/2017/10/17/making-business-with-chatbot-05433106

https://www.pypestream.com/insights/15-chatbot-use-cases-1/

http://www.businessinsider.com/sc/chatbots-future-customer-service-2016-9?IR=T

https://quickbooks-engineering.intuit.com/the-one-with-the-chatbot-using-api-ai-fb-messenger-c4c80ae9a07e

At first you need to undertsand three things Small TalkIntents and Entities about ChatBot :

  1. Small talk Intents. These intents are the opener or closer of a conversation.
  2. Intents ( or Business Intents  ) are the intentions of the end-user, these intentions or intents are conveyed by the user to your bot.
  3. Entities are metadata or parametres that compose each intent.

For this scenario i will create two intents GET_AGENTS_LIST and GET_AGENT_ITEM. GET_AGENT_ITEM will contain AGENT_ID as an Entity. Small Talk will be expression like Hi/Hello and Bye or Ciao.

Create Agent

From the left menu click Create new agent link

Choose a name for the agent like TEST_CHAT_BOT and click CREATE button

Step by step to create GET_AGENTS_LIST intent

Click Intent link in the left menu to create new intent

Enter GET_AGENTS_LIST in the field name and add few expressions as shown below. Check Use Webhook checkbox and click SAVE button after.

From to left menu clickFulfillement link

Put the XSJS script url, activate ENABLED and add X-CSRF-TOKEN = unsafe ( other wise you get an this error Webhook call failed. Error: 403 Forbidden ) as header param and click SAVE.

Test the Webhook call. Enter an expression of our intent and hit Enter. For more details click SHOW JSON button

{
  "id": "2fd52f6c-db3d-46db-93a2-19455b9375c4",
  "timestamp": "2017-11-28T08:19:10.335Z",
  "lang": "en",
  "result": {
    "source": "agent",
    "resolvedQuery": "Can you show me the agents list ?",
    "action": "",
    "actionIncomplete": false,
    "parameters": {},
    "contexts": [],
    "metadata": {
      "intentId": "12d39108-21bb-47d8-b465-bd75d754ccf5",
      "webhookUsed": "true",
      "webhookForSlotFillingUsed": "false",
      "webhookResponseTime": 1798,
      "intentName": "GET_AGENTS_LIST"
    },
    "fulfillment": {
      "speech": "Agents List:  FIRST_NAME7464LAST_NAME4174 FIRST_NAME2144LAST_NAME2099 FIRST_NAME6175LAST_NAME4180 FIRST_NAME0316LAST_NAME4742 FIRST_NAME5773LAST_NAME1122 FIRST_NAME3213LAST_NAME2971 FIRST_NAME9376LAST_NAME1463 FIRST_NAME7641LAST_NAME4544 FIRST_NAME1913LAST_NAME2868 FIRST_NAME1021LAST_NAME9984",
      "source": "source-of-the-response",
      "displayText": "Agents List:  FIRST_NAME7464LAST_NAME4174 FIRST_NAME2144LAST_NAME2099 FIRST_NAME6175LAST_NAME4180 FIRST_NAME0316LAST_NAME4742 FIRST_NAME5773LAST_NAME1122 FIRST_NAME3213LAST_NAME2971 FIRST_NAME9376LAST_NAME1463 FIRST_NAME7641LAST_NAME4544 FIRST_NAME1913LAST_NAME2868 FIRST_NAME1021LAST_NAME9984",
      "messages": [
        {
          "type": 0,
          "speech": "Agents List:  FIRST_NAME7464LAST_NAME4174 FIRST_NAME2144LAST_NAME2099 FIRST_NAME6175LAST_NAME4180 FIRST_NAME0316LAST_NAME4742 FIRST_NAME5773LAST_NAME1122 FIRST_NAME3213LAST_NAME2971 FIRST_NAME9376LAST_NAME1463 FIRST_NAME7641LAST_NAME4544 FIRST_NAME1913LAST_NAME2868 FIRST_NAME1021LAST_NAME9984"
        }
      ]
    },
    "score": 1
  },
  "status": {
    "code": 200,
    "errorType": "success",
    "webhookTimedOut": false
  },
  "sessionId": "9e01686e-82bc-498f-86e9-f7b6c2e8864b"
}

The Bot is working well in the next post i will integrate it with faceBook Messenger page.

Previous article Here Next article Here    

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Uttam Kumar
      Uttam Kumar

      Hi,

      I have created xsjs service. When running the chatbot by the providing the xsjs url in Fulfillment,adding header parameters  x-csrf-token = unsafe and making the package public, its giving the following error :

      “status”: {
      “code”: 206,
      “errorType”: “partial_content”,
      “errorDetails”: “Webhook call failed. Error: Request timeout.”,
      “webhookTimedOut”: true
      },

      When I run the url independently its giving the output.

      Please provide the solution.

       

       

      Author's profile photo Smriti Srivastava
      Smriti Srivastava

       

      Hi,

      Did you get any solution for this error. I am facing the similar issue. I am getting 500 - Internal Server error. Please reply if you got solution for this.

      Thanks

      Author's profile photo Manoj Kumar Thatha
      Manoj Kumar Thatha

      Hi Uttam,

       

      When i try to run url independently it gives error.

      Execution error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

      Please let me know how have created the xsjs script. I believe i am getting empty response that's why i am not getting above error. I cannot debug xsjs in web development editor. It is giving the error that WebSocket connection is not ready for debugging.

       

      Thanks,

      Manoj

      Author's profile photo Prakash Waddar
      Prakash Waddar

      Hi Uttam,

      Upload Trusted Certificate from   HCP in XSADMIN .Please find the below Snapshot.

       

      XS ADMIN Page URL.

      https://mdcp1942331530trial.hanatrial.ondemand.com/sap/hana/xs/admin/

       

       

      Regards

      Prakash waddar

      Author's profile photo 1234SOL ---TECH-USER---
      1234SOL ---TECH-USER---

      Hi Prakash waddar,

      Where I download the Trusted Certificate from HCP, you can send me the url page or the photo

      Regards,

      Rafael

      Author's profile photo 1234SOL ---TECH-USER---
      1234SOL ---TECH-USER---

      Hi Prakash waddar,

      Where I download the Trusted Certificate from HCP, you can send me the url page or the photo

      Regards,

      Rafael

      Author's profile photo Prakash Waddar
      Prakash Waddar

      Hi Rafael,

      Download (Export)  HCP Certificate from SAP HCP Cockpit into  you desktop then upload downloaded certificate in Trust manager . find  the below screenshot.

       

      Regards

      Prakash Waddar

      Author's profile photo Sameer Mehta
      Sameer Mehta

      After adding the certificate, I am still getting the same error. Please help