How can we build a bridge between different types of SAP applications? SAP BTP Kyma can be the bridge between SAP Conversational AI and SAP Analytics Cloud.
We can quickly build chatbot with no-code development and integration with the SAP ecosystem. With the SAP ecosystem, how can we easily visualize the data from chatbot to the dashboard?
We can build the Bridge with the SAP BTP Kyma🛠
With SAP BTP Kyma, we can integrate SAP Conversational AI and SAP Analytics Cloud. The connection bridge between SAP Conversational AI and SAP Analytics Cloud is through SAP BTP Kyma with oAuth2.
This is the high level architecture for this solution.
For the python application and SAP CAP Application, I referenced this blog about solution architecture. This article is really helpful to better understanding of dynamic oData through SAP BTP Kyma, please refer to this posting: https://blogs.sap.com/2021/09/09/dynamic-odata-from-any-api-through-sap-btp-kyma/)
To build this architecture with SAP BTP Kyma, let's check the followings.
Check Developer Token
import time
import configparser
import requests
import json
import os
import sqlite3
from requests.auth import HTTPBasicAuth
import configproperties
from collections import Counter
# Mapping function
def createExportList(chatlist):
conv = []
conv = chatlist
return conv
# To define the structure of the table
def createTableStructure(exportList):
tabStr = ""
dataModel = "namespace exportname.export;\n\nentity Conversations {\n"
fieldSequence = [0,1]
for item in exportList:
for i in range(2):
#dbfield = ''.join(field.split()).lower()
#[drink['content'], hat['content'], hatcolor, ticket['content']]
if i == 0:
tabStr = tabStr + "ID" + " TEXT, "
dataModel = dataModel + "ID" + " : String;\n"
elif i == 1:
tabStr = tabStr + "DATE" + " TEXT, "
dataModel = dataModel + "DATE" + " : String;\n"
break #for one entry
dataModel = dataModel + "}"
return tabStr[:len(tabStr)-2], dataModel, fieldSequence
#Create sqlite table
def createTable(con, tabStr):
try:
dbCur = con.cursor()
dbCur.execute("DROP TABLE IF EXISTS CatalogService_Conversations")
tableStructure = "CREATE TABLE IF NOT EXISTS CatalogService_Conversations (" + tabStr + ")"
dbCur.execute(tableStructure)
except Exception as e:
print(e)
#Fill database
def insertIntoDb(con, list, fieldSequence):
try:
dbCur = con.cursor()
for item in list:
placeholder = ""
dataset = []
for field in fieldSequence:
placeholder = placeholder + "?,"
dataset.append(str(item[field]))
placeholder = placeholder[:len(placeholder)-1]
dbCur.execute("INSERT INTO CatalogService_Conversations VALUES (" + placeholder + ")", dataset)
except Exception as e:
print(e)
def main():
exportList = createExportList(chatlist)
# Store the list as SQLite DB to tbe picked up by CAP
tableStructure, dataModel, fieldSequence = createTableStructure(exportList)
conSql = None
try:
conSql = sqlite3.connect('./dbdata/cai-items.db')
except Exception as e:
print(e)
if conSql != None:
createTable(conSql, tableStructure)
insertIntoDb(conSql, exportList, fieldSequence)
conSql.commit()
conSql.close()
#Create data-model.cds if it doesn't exist
if not os.path.isfile("./dbdata/data-model.cds"):
dataModelCds = open("./dbdata/data-model.cds","w")
writtenBytes = dataModelCds.write(dataModel)
dataModelCds.close()
#Wait before the enxt call
time.sleep(refreshTimer)
if __name__ == "__main__":
main()
Select a Data source
Create new new model from a data source
Select a data source
Create Model from OData Services
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
20 | |
9 | |
9 | |
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |