Skip to Content

Integrate Chatbot with SAP Build Process Automation

Integrate SAP Build Process Automation with SAP Conversational AI using API Triggers and Notifiers
You will learn
  • How to add API Trigger and Notifiers to an automation
  • How to send data from a chatbot and trigger an automation in Unattended mode
shielddzIlyes YamounDecember 8, 2022
Created by
celineaudinsap
November 20, 2022
Contributors
celineaudinsap
pbujnicka

In this tutorial you will retrieve the specific Sales Order details through a chatbot (SAP Conversational AI) that interacts with your SAP Build Process Automation project.

  • Step 1
    1. Open the project you created in SAP Build Process Automation Application Capture.

    2. Add Agent Attribute.

      Agent Attribute
    3. Release the project.

      Release the project
    4. Deploy the project. Click Deploy.

      Deploy button
    5. Select Create a Trigger and click Next.

      Trigger creation
    6. Select API and click Next.

      Trigger type selection
    7. Select Get Order Details From Application automation and click Next.

      Trigger automation selection
    8. Set Name to Get Order Trigger and click Next.

      Trigger Name
    9. Click Confirm then hit Deploy.

      Confirm and deploy project

      The project is now deployed.

    Log in to complete tutorial
  • Step 2
    1. Go to lobby landing page of SAP Build.

      Lobby Page
    2. Go to Settings > API Keys.

      API Keys page
    3. To create your API Key. Click Add API Key.

      Add API Key
    4. Set Name to myAPIKey and click Next.

      • Select both options trigger_read and trigger_execute and click Next.
      Select Scope
    5. Click Add.

      Add button
    6. Click Copy and note down what was just copied to your clipboard.

      Copy API key

      It’s important to save your API Key, since it can only be read once from the Setting.

      Your API Key is now created and ready to be used.

    Log in to complete tutorial
  • Step 3
    1. Navigate to SAP BTP Cockpit subaccount > Services > Instances and subscriptions.

    2. Choose Create.

      Navigate to instances and subscriptions
    3. For the new instance:

      • Select SAP Build Process Automation as Service.
      • Select Standard Instance plan from the Plan list.
      • Select Other as Runtime Environment.
      • Set Instance Name as SPA-instance.
      • Choose Create.
      Instance details
      The instance is now added.
    4. Create a new Service Binding by selecting your SPA-instance instance > Select to expand > Create Service Binding.

      Navigate to Service Bindings creation tab
    5. Put the name as myServiceBinding and click Create.

      Name the service binding and create it
    6. Click and then click View to view the Service Binding created.

      View Service Binding
    7. Click Form and copy the clientid, clientsecret and URL under the uaa section. You will need it in the next steps.

      Note down information
    Log in to complete tutorial
  • Step 4
    1. Navigate to Home > Monitor > Manage > Automations.
    2. From the shown triggers:
      • Find your trigger (Created in Step 1.4 during deployment).
      • Click on Actions and select Edit.
      Edit Trigger
    3. Copy URL and Payload.

      Copy Info

      You can notice that the inputs of the automation are specified in the request body also called as the Payload.

    Log in to complete tutorial
  • Step 5

    A ready CAI bot is used here.
    This bot has a goal of emitting an API Call to SAP Build Process Automation using API Trigger, API Key and Service Binding we created previously.

    Using CONSUME API SERVICE feature in Conversational AI bot we can make API Calls.

    1. Set URL to the one saved in step 4.

      Set URL
    2. For Authentication tab:

    • Set Authentication type to OAuth2 Authentication.
    • Set Client ID, Client Secret and Authorization URL to those saved in step 3.

      For Authorization URL add /oauth/token at the end of the URL.

      Authentication tab
    1. For Headers tab:

      • Click + New Fields to create a new field.
      • Set Key to irpa-api-key and Value to the one saved in step 2.
      Headers tab
    2. For Body tab:

      • Select Create a custom body.
      • Paste the following:
      JSON
      Copy
      {
          "invocationContext": {
          "conversationId": "{{conversation_id}}"
          },  
          "input": {
              "orderNumber": "Order {{memory.orderNumber.raw}}"
          }
      }
      
      Body tab

      memory.orderNumber.raw is just a variable where an order number given by a user is stored.

    3. Click Save to save your changes.

    Is adding /oauth/token to the Authentication URL mandatory?

    Log in to complete tutorial
  • Step 6
    1. To get Bot Developer Token:

      • Go to Settings > Tokens.
      • Note Developer Token somewhere and save it.
      CAI Developer token
    2. To get Designtime API Token:

      • Click Generate besides Designtime APIs.
      • Select Client Credentials and click Next.
      • Note Auth URL, Client ID and Client Secret somewhere and save it.

        Don’t confuse these 3 information with those of the service binding’s.

      CAI Designtime API token
      We now have the proper tokens to create Notifiers.
    Log in to complete tutorial
  • Step 7
    1. Navigate to Home > Monitor > Manage > Automations.

      Find Trigger
    2. Start Notifier:

      • Click three dots under Actions in the same row as your Trigger.
      More options in screen
      • Select Add Notifier.
      • Select CAI and click Next.
      • Create the notifier as such:
      Field Name Value
      Notify on Start
      Name Starting notifier
      Description Indicates that the automation has started
      Conversation ID${invocation_context.conversationId}
      Token Developer token from step 6.1
      Auth URL Designtime APIs token Auth URL from step 6.2
      Client ID Designtime APIs token Client ID from step 6.2
      Client Secret Designtime APIs token Client Secret from step 6.2
      What do you want to do? Send a message
      Delay in second 0
      Message content IRPA: Bot Started.
      • Click Create.
    3. Success Notifier:

      • Click
        More Options button
        under Actions in the same row as your Trigger.
      • Select Add Notifier.
      • Select CAI and click Next.
      • Create the notifier as such:
      Field Name Value
      Notify on Success
      Name Success notifier
      Description Indicates that the automation has finished successfully
      Conversation ID${invocation_context.conversationId}
      Token Developer token from step 6.1
      Auth URL Designtime APIs token Auth URL from step 6.2
      Client ID Designtime APIs token Client ID from step 6.2
      Client Secret Designtime APIs token Client Secret from step 6.2
      What do you want to do? Send a message
      Delay in second 0
      • Set Message content:
        ${output.order.orderNumber}:
        Price: ${output.order.orderAmount}€.
        Status: ${output.order.orderStatus}.
        Order Date: ${output.order.orderDate}.
        Country: ${output.order.shippingCountry}.
      
      • Click Create.
      Create Notifiers
    4. Error Notifier:

      • Click
        More Options button
        under Actions in the same row as your Trigger.
      • Select Add Notifier.
      • Select CAI and click Next.
      • Create the notifier as such:
      Field Name Value
      Notify on Failure
      Name Failure notifier
      Description Indicates that the automation has failed
      Conversation ID${invocation_context.conversationId}
      Token Developer token
      Auth URL Designtime APIs token Auth URL
      Client ID Designtime APIs token Client ID
      Client Secret Designtime APIs token Client Secret
      What do you want to do? Send a message
      Delay in second 0
      Message content Automation failed with error: ${error.details}
      • Click Create.
      Create Fail Notifiers
      The three notifiers are now created.

    Will a Success notifier work if a Start notifier isn't created?

    Log in to complete tutorial
  • Step 8
    1. Open your SAP Conversational AI chatbot.

    2. Click Connect tab.

    3. Click on SAP Conversational AI Web Client.

      SAP Conversational AI Web Client
    4. Put CAI with IRPA in Channel Name and click Create.

      Create Channel
    5. Click on the Web Client standalone link to open the chatbot in browser.

    6. The chatbot opens in a new window.

      Open Chatbot in new Window

      Make sure your Desktop Agent is in Background (Unattended) mode.

    7. To start my bot I type Start my automation according to what I set it up to respond to (Execute the API call) after asking for an order number.

    8. The workflow of the execution:

      • The process starts with the user triggering it in the chatbot (sending Start my automation).
      • The chatbot asks for an Sales Order Number which will be used as an input for our automation.
      • Once the Order Number is submitted by the user, the bot sends the API Request to SAP Build Process Automation according to what we configured it, and displays CAI Bot: Emitting the API Call.
      • Once the API Request is reached, the SAP Build Process Automation Start notifier sends back a message declaring its start: IRPA: Bot Started.
      • Upon a successful execution of the automation, the Success notifier is triggered and the Sales Order’s details are returned to the bot that displays them.
      Response From SPA

    Log in to complete tutorial
Back to top