Skip to Content
Technical Articles
Author's profile photo Ralph Oliveira

B1 Assistant – Retire your keyboard with SAP Business One and Alexa

Update April 2020:

Thank you for your interest in the B1 Assistant. The original prototype has been modified a lot since its inception. The goal was to make it simpler to deploy so more and more partners could use it. The result, is the B1 Assistant Lite which can be deployed in minutes. It has a smaller functionality scope but completely serves its purpose: to enable you in how the integration works and how to work with Alexa. The whole deployment, together with a conceptual presentation can be found in the video below.

If you still want to deploy the first released version, please continue to the original below:

 

ORIGINAL POST – 10/10/2016

You’ve probably heard about a prototype we demo at the ASUG Summit in Miami. The proposal was to present how easy companies can embrace the digital economy transforming their business on daily tasks (if you haven’t seen that before, you are probably not following the right people on twitter).

A bit different from what some of you asked me, this is not a core feature of SAP Business One, it’s a prototype developed by the Solution Architects team, just like many others we shared before.

Good news the code is open for you to use and implement your own version. And here is a tutorial of how to install the B1 Assistant and “retire” your keyboard for some B1 tasks.

So, grab your popcorn, sit tight, follow me on twitter and enjoy this how-to!

The Architecture

Alexa  (Amazon Echo’s persona) has several capabilities (Skills). Those are divided between Native (time, weather, traffic, news…) or 3rd Party (Uber, Spotify, Business One…)

To activate the 3rd party skill, we use Invocation Names. Those are nothing more than the name of the skill we want to call. For example: “Alexa, ask Uber for a ride” or “Alexa, open Spotify”. Once it hears your command, it will identify the skill to be triggered and call a specific Web Service that can be hosted on a Private Cloud or on AWS. Like this:

In our case, working the with B1 Assistant Skill the architecture is:

It’s not my intention to get into details about skill. I strongly suggest you take a look at Alexa’s documentation. It’s highly informative

 

Skills details

Beside the Invocation Names, the skills have 2 other attributes, the intent, which is the specific action to be activated and the slots that works as parameters of the first one.

Implementing the B1 Assistant

Enough with definitions and small talk, let’s go for the funny part. So you can have your own B1 Assistant.

Prerequisites

All the code used in this tutorial is shared on github

1 – Deploying the B1 Assistant HANA app

We’ve seen that whenever a user asks Alexa , it will trigger a Skill, this skill will call a function and this function will interact with an application (SAP Business One)

So let’s build our stack, starting by the end. The B1 Assistant App on HANA.

There 2 options for this part:

Whatever the case, once you have the b1Assistant package on your HANA system.
Go to HANA Administration Tools dashboard (http://hanaserver:8000/sap/hana/xs/admin) and set a user and password for the file: b1Assistant > lib > annonuser.xssqlcc

Note: Alexa will use this user to retrieve data and access the services.
You can also access http://hanaserver:8000/b1Assistant to test your app back-end

note: B1 user/pass is set on services/b1call.xsjs file

 

2 – Creating the B1 Assistant Skill

Create a new Alexa Skill following these steps. When asked for a Model choose Custom.

Next part we need to customize and build the skill.

On the Skill menu, choose the option JSON Editor. Replace its content with the model on our GitHub.

Click Save then Build your model

 

3 – Creating the B1 Assistant Function

With the HANA App deployed, we need a function to call its services (Create orders, item recommendation, sales info).

As mentioned before, we have a couple options to do this. Both demonstrated on this video

Option 1 – Using Amazon Web Service Lambda Functions

Option 2 – Run the app on SAP Cloud Platform – Cloud Foundry

Sample output when the app is successfully deployed on SAP Cloud Platform

4 – Link the function to your Alexa Skill and Test.

Last step!

Whatever option you choose before, at the end you should have an enpoint for your function. I.e, an ARN if you are using Amazon Lambda, or an URL if you pushed the app to SAP Cloud Plaftorm.

Back to the Amazon Developer Console (the same as step 2). Choose the right the menu Endpoint and set the right option for your case.

Choose the type of Endpoint for you case and set the address. More about endpoints here

Save your settings and build your model again!

Your B1 Assistant is ready to work! You can use the Test Console, the Echo Simulator or with a real Amazon Echo by enabling the Skill on your Alexa app. Which is much cooler ?

 

Spit it out!

Do you like it? Or maybe you hate it? Have any questions? Feel free to ask and let your comments below. Your feedback it much appreciated.

Special Thanks to the SAP Business One dev team in Shanghai that helped us with the predictive analysis feature! You rock!

 

B1 Assisant got smarter!!

There is a very cool enchament on this prototype made by Yatsea Li, integrating it with the Twitter Sentiment App. If you want to give your B1 Assistant more powers, once you fisished this tutorial, follow the instructions in his blog

 

Assigned tags

      37 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Iran Udayanga
      Iran Udayanga

      Hi Ralph
      Very interesting. Is it possible to use our own SAP HANA server and Window Cortana)? Without using Amazon web instance and Amazon echo unit.

      Thank You
      Iran

       

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      If Cortana has a SDK it sure is.. The backend could be exactly the one I am sharing here, you will have to adapt only the Windows Cortana calls.

      Author's profile photo Iran Udayanga
      Iran Udayanga

      Hi Ralph,

      Thank you very much for your advice.

      Thank You, Iran

      Author's profile photo Former Member
      Former Member

      Hi Ralph,
      I have the prereqs SAP Business One 9.2 PL04 and SBODEMOUS schema available, but not on hana. We are running on sql database, with microsoft sql server. Is it possible to integrate with alexa?

      regards harsha

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      Hi Harsha.. This prototype is only available on HANA. It uses XSEngine and Service Layer, assets that are no available on B1 on MSSQL

      Author's profile photo Karlo Mesquita
      Karlo Mesquita

      Hi Ralph,

      I would like to use Integration Framework 2.0 in SQL Server with Service Layer in SAP 10 PL01 for this integration. Is it possible?
      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      Hi Karlo, it should be possible.

      My only question would be: why?

      Author's profile photo Karlo Mesquita
      Karlo Mesquita

      I saw workflow in B1if and many possibilities for integration that would work both in Hana and in SQL server without the need for adaptations. For Alexa need was just for reporting calls.

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      But on V10 you got also the Service Layer on SQL, right?

      You could keep the same stack.

      Author's profile photo Former Member
      Former Member

      Hello, Ralph, that's fine.

      I'm trying to do the 1 part of your tutorial (1 - Deploying the B1 Assistant HANA app)
      And I have 2 options:
      I import b1Assistant application delivery unity or I get a clone straight from your github and create my own Project XS.
      Well, I'd like to import yours, so I minimize my mistakes. 🙂
      When I click on the link that you placed (how to import a delivery unity), it is not working. I do not know how.

      Please, could you pass me as I do this import?

       

      Best regards,

      Fernando Fonseca

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      Thank for the heads up. Apparently Help.sap changed the pages.

      I update the link with a new tutorial. check it again 🙂

       

      Author's profile photo Former Member
      Former Member

      Hi Ralph,

       

      Perfect, and now mine Alexa is working very well !!!

       

      Thank you so much.

      Fernando Fonseca

      Author's profile photo Greg Lewis
      Greg Lewis

      Hi Ralph,

      This dropbox link no longer works (for the delivery unit): https://www.dropbox.com/s/xpc7i7glng64goe/B1_ASSISTANT-b1.solution.architects.tgz?dl=0

      Is there a working link for the delivery unit?

      Greg

      greg.lewis@fameintel.com

      Author's profile photo Chin Chong
      Chin Chong

      Hi Ralph,

      The b1Assistant.js that is installed in Amazon Lambda only has the setting for the

      var g_hdbServer = 'our Hana Server';
      var g_hdbPort = 8000; // Http(8000) or Https(4300)

      In our case, we are using our internal servers. How does the code in Lambda access SBODEMOUS data without a B1 user ID (e.g. "manager") and password?

      Kind regards

      Chong Chin

       

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      you need to expose port 8000 or 4300 to the internet. Otherwise lambda won't access your server.

      Author's profile photo Yatsea Li
      Yatsea Li

      Hi Chin Chong,

       

      Apart from AWS lambda function, Now you also could deploy the b1assistant alexa skill in our local server or SAP Cloud Platform CF, please refer to this tutorial:

      Deployment options of B1Assistant Alexa skill

      Latest source code of b1Assistant available here:
      https://github.com/B1SA/b1Assistant

      Kind Regards, Yatsea

      Author's profile photo Chin Chong
      Chin Chong

      Hi Ralph,

      1.  Within the Alexa testing tool, in AWS Developer site, I can successfully get the following

      a)  Open be one  > correct answer

      b)  I need sales reports  > Response:  asks for item group

      c)  Electronics > Response:  asks for quarter

      d)  First quarter > Response:  asks for year

      e) Two thousand and eleven > Response: "I am sorry, but there are no Electronics sales in the 1st quarter of 2011"

      But the data exists in the standard SBODEMOUS.

      2.      I tried with the Echo simulator

      a) Open Be One  > correct response

      b)  I need sales reports  > Response:  I have put sales reports in your shopping list

      3.  We have already open the ports to the internet. There were no access errors in both - AWS Developer or Echo simulator

      4.   In our installation, the B1SL is installed in a separate VM from the Hana DB server. In b1Assistant.js, in Lambda, I have written down the IP of the Hana DB server.

      Please let me know what could possibly be wrong with the above. Alexa appears to be integrated with Lambda, and there are no errors regarding access issues.

      Kind regards

      Chong Chin

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      The line 2b) is very weird, i would say to you deactivate/active the B1 Assisant skill on the alexa app again.

       

      But this protoype considers that both HANA and SL are on the same server. You will have to change the /bin/http/B1SL files to point to the right server. Otherwise it will fail in the creation of  Orders

      Author's profile photo Chin Chong
      Chin Chong

      Hi Yatsea,

      Sorry for the delayed response. For some reasons, I am not getting an alert when a posting is made to this blog.

      I have gone through your video to B1 Asisstant version 2, with the additional 2 new deployment options and also the additional new questions that we can pose.

      Thank you and kind regards

      Chong Chin

      Author's profile photo Hendra Prakasa
      Hendra Prakasa

      Hi Ralph,

      There's a lot amazon echo version, which one do you recommend using ? is it all the same functionality ? and what's the best version of echo ?

       

      Regards,

       

      Hendra

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      They run all the same SW (a part from the ones with screens). So you can get the one you like most.

       

      Author's profile photo David Almazan
      David Almazan

      Hi Ralph,

      I am trying to start working with Alexa but

      The dropbox link no longer works (for the delivery unit):

      https://www.dropbox.com/s/xpc7i7glng64goe/B1_ASSISTANT-b1.solution.architects.tgz?dl=0

      Could you help me with this?

      Dave

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      fixed, shared another link

       

      Author's profile photo David Almazan
      David Almazan

      Thanks Ralph, now it is working!!

       

       

      Author's profile photo maen mostafa
      maen mostafa

      link is broken ,

       

      https://www.dropbox.com/s/xpc7i7glng64goe/B1_ASSISTANT-b1.solution.architects.tgz?dl=0

       

      no delivery unit , can you come and help ..

       

      thank you

       

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      fixed, shared another link

       

       

      Author's profile photo maen mostafa
      maen mostafa

      hello Ralph ,

       

      i am searching for delivery unit since 3 days and the link broken , we are SAP partners and you should help , i tried to clone with SAP HANA but showing this errors , seems something missing , because even the link in GitHub , does not explain the requirements before clone project , when i cloning project it is showing these errors :

      please help or upload Delivery Unit here or any correct link , we need it for Demonstration for potential customers

       

       

       

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      fixed, shared another link

      check blog plz

      Author's profile photo maen mostafa
      maen mostafa

      Hello ,

      please provide us with Delivery Unit , i am unable to build it , i cloned it but still showing same errors , please upload delivery unit ASAP , building project is not clear and no resources to help common please

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

       

      fixed, shared another link

      check blog plz

       

      Author's profile photo maen mostafa
      maen mostafa

      hi ralph ,

      i set all required parameters in B1Assistant delivery unit , like username and password of SBODEMOUS , and hana server address , when i attempt to test skills using amazon skills , the same one i built this is response

       

      please advise ..

      ==========

      be one

      Hello, here is B1 assistant. Let me know what do you wish.

      give me sales info

      Which Item Group do you want to know?

      pcs

      Which Item Group do you want to know?

      pc

      Got it! What quarter?

      first

      What year do you need?

      2014

      There was a problem with the requested skill's response

       

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      Take a look at the amazon Cloud Watch

      It has a console with all the logs from your lambda function. You might find more details in there.

      Author's profile photo maen mostafa
      maen mostafa

      hi ralph ,

       

      i review the code of index.html , when i click on get recommendation i got error , i think this is because different version of HANA , i am using 1.0 rev 12 :

      in the code

      var path = B1XAddress +
      "pervasive/IMCC/srv/pa/service/sale_recommend"+
      "?cardcode="+body.CardCode;

      b1xaddres = /sap/sbo

       

      i searched for sale_recommendation , nothing exist , there is salesrecommendation js file :

       

      sap/sbo/pervasive/IMCC/resources/js/pa/sidebar/salesRecommendation.js

      because your path mentioned in the code no longer exist .

      note i am using 9.3 PL1

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      I never tested it with 9.3, but those paths are referenced by the B1 Extreme App Framework

      As shown in the video, you have to initialize the predictive services before consuming them.

       

      Author's profile photo maen mostafa
      maen mostafa

      another note in the code

      even platform/env does not exist in all of delivery units

       

      please advice

      Author's profile photo Ralph Oliveira
      Ralph Oliveira
      Blog Post Author

      As mentioned in my previous comment.

      Paths are referenced by the B1 Extreme App Framework.

      They are not from my the app itself.

       

      Author's profile photo Roger Masias
      Roger Masias

      Dear Ralph,

      Thank you very much for the contribution, I'm trying to do with the "Create Sales Order" button and it returns "Internal Server Error", which I could review?

      Kind regard