Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
YatseaLi
Product and Topic Expert
Product and Topic Expert

Overview


My colleague ralph 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=js... (****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=j... 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).
4 Comments