Overview

My colleague  has published a blog about B1 Assistant – Retire your keyboard with SAP Business One and Alexa, showing how to build a conversational user interface(named B1 Assistant) for SAP Business One with the voice control platform-Amazon Alexa. In which you can ask Alexa about the sales result of Item Group Printers for Q1 of 2017 from SAP Business One, even ask Alexa to place a purchase order with recommended item into the SAP Business One system etc.

B1Assistant helps executives with Business Questions

In this blog, I am going to show you some new scenarios about how SAP Business One Assistant powered by Amazon Alexa helping executives with business questions such as:

  • How is my business doing?
  • What are top 5 best selling products?
  • How is my sales pipeline this quarter?
  • How is my best selling product doing on social media?
    The B1 Assistant will do the sentiment analysis of the tweets about your predefined product hashtag, and answer you how much portion and how may positive or negative tweets talking about my product problem.
  • Ask Alexa to read you some positive or negative tweet about your product hashtag.

How easily you can add a new skill to B1Assistant(Alexa) to answer a new business question by leveraging

  • The predefined Semantic Layer(Business Analytics) and Service Layers(Transaction) of SAP Business One
  • HANA XSJS or XSOData, Text Analysis/Sentiment Analysis etc of SAP HANA platform.

Imaging you are a SMB business owner, CEO or CFO etc.

Scenario#1.Wake up in the morning at home, and you want to check with Alexa the business status, sales pipeline, and your besting product or company brand on social medial through a conversation below without any screen.

Scenario#2.In your executive meeting, Alexa acts as a standby virtual business assistant in the meeting room to answer your business questions about the overall business status, sales pipeline of the quarter, and your besting product product or company brand with sentiment Analysis on social medial. Further more you can dive into more details in the Digital Board Meeting Room like screens. In this video, the voice controlled SAP Business One assistant powered by Amazon Alexa will have a conversation about your business as below:

The actual questions to ask Alexa:

  1. “Alexa, open B1.” (wait for alexa respond) then ask.“How is my business doing?”
  2. “Alexa, ask B1 for top 5 items.” or “Alexa, ask B1 for top 3 items.” (top number as dynamic input)
    Or “Alexa, open B1”, then “What are best selling products?”,
    Alexa will ask you “How many top items?”
    You can respond with “Top 3 items.”
  3. “Alexa, open B1″. Wait for Alexa respond, then ask.“How is my Sales Pipeline for this quarter”
    or simply ask without saying open b1:”Alexa, ask B1 for Sales Pipeline update for this quarter”
    or “Alexa, ask B1 to get me Sales Pipeline update for last quarter”
  4. Alexa, open B1″(wait for alexa respond) then ask.“How is my product doing on Social medial?”…..
    Alex will ask you “Do you want me to read some negative tweet”
    You can reply as “Yes” or “Not”or simply ask:”Alexa, Ask B1 for social medial update.”
  5. “Alexa, ask B1 to read me some positive tweets”

Architecture and Technical Details

The architecture remain the same as Ralph described in this blog.

For the business questions of Sales analysis, Sales Pipeline analysis,
It is using the predefined semantic layer of SAP Business One by SAP to extract the business context. Specially, they are SalesAnalysisQuery and SalesOpportunitiesQuery. Please refer to the document how to work with semantic layer for SAP Business One.(S-number login required)

The toppings added up to the semantic layer are:

  • For Sales Analysis, I have created a procedure(location: /b1Assistant/procedures/getSalesInfo.hdbprocedure) to get the sales result of this month, last month and the same month of last year from the SalesAnalysisQuery model with query. then have a XSJS named wrap up the final results. Therefore, the B1Assistant in Alexa can invoke it with a simple REST call and build out the output speech.GET https://<YOUR_HANA_SERVER>:4300/b1Assistant/services/getBusinessInfo.xsjsResponse sample in JSON format:
    {“OverallStatus”:”Not So Good”,”Currency”:”$”,”CurrentPeriodResult”:{“NetSalesAmountLC”:”66172″,”GrossProfitLC”:”42172.73″,”GrossMargin”:0.637,”YoYSalesGrowthRate”:-0.93,”MoMSalesGrowthRate”:-0.653},”LastPeriodResult”:{“NetSalesAmountLC”:”190856.14″,”GrossProfitLC”:”72994.19″,”GrossMargin”:0.382},”SamePeriodLastYearResult”:{“NetSalesAmountLC”:”938812.37″,”GrossProfitLC”:”436833.63″,”GrossMargin”:0.465}}
  • For Sales Pipeline Analysis, a HANA XSOData(location:  /b1Assistant/services/BusinessInfo.xsodata) is created on top of SalesOpportunitiesQuery.GET https://<YOUR_HANA_SERVER>:4300/b1Assistant/services/BusinessInfo.xsodata/OpportunityQuery$format=json&$select=PotentialAmountLC,WeightedAmountLC,NumberOfOpportunity,AverageClosingPercentage,OpportunityStatus&$filter= (****Dynamic filter for OpportunityStartYear and OpportunityStartQuarter etc*****)Sample of sales pipeline for Q2 of 2017
    https://<YOUR_HANA_SERVER>:4300/b1Assistant/services/BusinessInfo.xsodata/OpportunityQuery?$format=json&$select=PotentialAmountLC,WeightedAmountLC,NumberOfOpportunity,OpportunityStatus,AverageClosingPercentage&$filter=OpportunityStartYear eq ‘2017’ and OpportunityStartQuarter eq ‘Q2’
  • Response sample in JSON format:
    {“d”:{“results”:[{“__metadata”: {“type”:”b1Assistant.services.BusinessInfo.OpportunityQueryType”},”OpportunityStatus”:”Lost”,”PotentialAmountLC”:”8000″,”WeightedAmountLC”:”4000″,”AverageClosingPercentage”:”50″,”NumberOfOpportunity”:1},{“__metadata”: {“type”:”b1Assistant.services.BusinessInfo.OpportunityQueryType”},”OpportunityStatus”:”Open”,”PotentialAmountLC”:”17000″,”WeightedAmountLC”:”8500″,”AverageClosingPercentage”:”50″,”NumberOfOpportunity”:2},{“__metadata”: {“type”:”b1Assistant.services.BusinessInfo.OpportunityQueryType”},”OpportunityStatus”:”Won”,”PotentialAmountLC”:”5000″,”WeightedAmountLC”:”4750″,”AverageClosingPercentage”:”95″,”NumberOfOpportunity”:1}]}}

For the Sentiment Analysis of tweets about the best selling product

  • The Twitter API to stream the tweets of certain hashtag into SAP HANA(in the demo, it is #iMiniServer, which is the best selling product in my B1 system)
  • The built-in Sentiment Analysis of SAP HANA to extract the social medial context. You can refer to this blog SAP HANA Real Time Sentiment Analysis and Text Mining app for detail explanation about Twitter API and Sentiment Analysis in SAP HANA.

Tweets table and full text index

  • –Alexa tweets table
    “SUMMIT2015″.”Summit15.data::alexatweets”
  • — Create FT Index Tweets Brands
    CREATE FullText INDEX “ALEXAB1TWEETS” ON “SUMMIT2015″.”Summit15.data::alexatweets” (“Text”)
    LANGUAGE COLUMN “Language”
    TEXT ANALYSIS ON
    TEXT MINING ON
    CONFIGURATION ‘EXTRACTION_CORE_VOICEOFCUSTOMER’;
  • — Create FT Index Tweets Location
    CREATE FullText INDEX “ALEXAB1LOCATION” ON “SUMMIT2015″.”Summit15.data::alexatweets” (“Location”)
    LANGUAGE COLUMN “Language”
    TEXT ANALYSIS ON
    CONFIGURATION ‘EXTRACTION_CORE’;

Tweet Sentiment Analysis by b1Assistant:

  • /b1Assistant/models/CA/B1TweetSentiments.calculationview (HANA model for analysis)
  • /b1Assistant/procedures/getSocialMediaInfo.hdbprocedure
    (HANA procedure to get sentiment analysis result)
  • /b1Assistant/services/getSocialMediaInfo.xsjs
    (XSJS to call the procedure and wrap up the final output)
    GET https://<YOUR_HANA_SERVER>:4300/b1Assistant/services/getSocialMediaInfo.xsjs{“TweetTotalCount”:8,”TweetCountWithSentiment”:7,”PositiveTweetCount”:4,”NegativeTweetCount”:3,”TweetCountWithProblem”:2,”PostivePerc”:0.571,”Status”:”Not So Good”,”NegativePerc”:0.429,”ProblemPerc”:0.286}

Try it out

Source code available on Github (as a branch of the original b1Assistant by ralph) with AS-IS license. No SAP official support available. Feel free to extend or modify it. If you have any feedback or questions, please post a comment in this blog.

Pre-requisites

Installation

Important: Please follow the perquisites and steps mentioned in Ralph’s blog and the READ.ME in Github

You must install the prerequisites projects b1Assistant and StructureOne mentioned above in your SAP HANA, then import and overwrite the code on this branch on top of the original B1 Assistant App. I am planing to decouple the dependence with StructureOne in the near future, which you have to just install the only updated version of b1Assistant(master branch).

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

    1. Yatsea Li Post author

      Dear  Varkey,

      Actually it could be very easy ported to ECC/S4HANA or BW. Given the reasons below;

      1.It is loosely coupled architecture. All the communication between backend ERP service , AWS Lambda service and Alexa through HTTP(S)/OData. So you can easily replace the Backend ERP service API with gateway of ECC, S4/HANA.

      2.It is purely SAP HANA technology, Semantic Layer here is actually SAP HANA CalcView. S4/BW have tons of such HANA Model to be exposed with XSJS or XSOdata. SAP Business One share the same SAP HANA Platform as S4/HANA and BW on HANA.

      This is an innovation PoC of building conversational User Interface with Amazon Alexa and ERP system powered by SAP HANA for our partners&cusromet reference. The source code is available as open source on GitHub under SCN ASIS license. You can take it and extend it on your own purpose. We have a few B1 partners have already take it on their own and build their own scenario, such as AchieveIT from USA, ask Alexa about the bin location of items in warehouse, what is best option for pick&pack, etc…

      As you see, With SAP HANA, we bring more and more intelligence to the ERP, with conversation UI powered by voice control platform such as Alexa, it free our hands.

      Kind Regards, Yatsea

      (0) 
        1. Yatsea Li Post author

          Dear Varkey,

          Cool. Feel free to post your questions here if you need assistance.

          And please keep me posted. I’d love to see it on ECC or S4.

          Kind Regard, Yatsea

          (0) 

Leave a Reply