Chat with your Home Assistant: SAP Conversational AI

Hello guys,
Would like to chat with your home assistant ?
I found an awsome way to create a chat bot with your own data from home assistant — SAPCAI( SAP conversational AI).

SAPCAI is a powerful tool. With it, just with some clicks, you can build your own chat bot and it is free.

  1. Your home assistant can be connected from Internet.

  2. Register a user in https://cai.tools.sap/

  3. Create a bot with Perform Actions

  4. Chosse the type of this bot like greetings, small talks, etc. Of course you can extend your own functions by training the bot.

  5. After the bot is created, click on the build tab. Here we will configure the greetings as example.

  6. In the configuration, it is similar to home assistant’s automation with triggers, conditions and actions.
    Here we only need to set the actions. We will add an API Service Configuration by clicking on Connect External Service .
    How to call home assistant’s api, please check here.

Hi there! Current weather is {{api_service_response.default.body.state}}. Temperature is {{api_service_response.default.body.attributes.temperature}} degree.

The result will be stored in the api_service_response. Now our bot is created. It will anlyse your input text, if it is @greetings, it will anwser me with weather information.

  1. Let’s test it! Go back to previous steps. Click on Connect tab and choose Webchat


    Create a html file and insert your own code.
<!doctype html>
<html>
<head>
    <title>SAP Conversation AI</title>
</head>
<body>
    <script
        src="https://cdn.cai.tools.sap/webchat/webchat.js"
        channelId=" replace to your own ID"
        token=""
        id="">
    </script>
</body>
</html>
  1. Open your Html and start chatting with it.

  2. More !
    You can chat with it in other platforms.


    The bot can reply you not only with plain text but other elements, You can use it to list all lights in your home , and you click one to turn it on.

    Here is tutorial Consume API Services and Call Webhooks from Your Chatbot | Tutorials for SAP Developers
    If you would like to create a service to talk to SAPCAI, you could call their APIs.

    result = requests.post( cai_base_url+conversation_url, json=body,headers={ "Authorization" : "Bearer " + get_token(), "X-Token" : "Token " + configproperties.requesttoken })

3 Likes