Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Dan_Wroblewski
Developer Advocate
Developer Advocate
1,425
Since February, you have had to use an OAuth tokens to access SAP Conversational AI APIs for new bots. It's simple, and I have written 2 tutorials on how to retrieve and then use the OAuth token to make API calls.




  • Call SAP Conversational AI API Using OAuth (Postman): Shows how to create a Postman collection of calls that determine when you need to refresh the OAuth token and then how to get it and make API calls. It's a little more than what you need, but it's a good chance to understand some of the Postman functionality, how to script, how to string multiple calls together, and how to set up tests.



 

Quick Call from Postman


I suggest you do the tutorials above. But I also wanted to show you how to use the OAuth functionality of Postman to quickly call the APIs. Here's how:

  • Open Postman and create a new request.

  • Set the URL to https://api.cai.tools.sap/v2/request and the method to POST. (Really, you should doublecheck the URL is correct when you get the token for your bot, lower down, there it will show the correct URLs for the SAP Conversational AI request APIs.)

  • Set the body to raw with the following JSON (or whatever message you want to send to your bot):


  • {     
    "text" : "hi"
    }


  • Add headers:

    • Add a header called X-Token, and set the value to the request token, which you can find in your bot at SettingsVersionsRequest Token. This indicates the version of the bot you want to call.

    • Add a header called Content-Type and set to application/json.







  • Under Authorization, set the type to OAuth 2.0, and in the form enter the Auth URL, Client ID and Client Secret. These parameters can be find in your bot at SettingsTokensOAuth Client.





  • Click Send.


You should now get the intents and entities from the NLP.


You can do the same to get the messages for the user using the /dialog API.

Here's the documentation on how to configure the runtime API calls, including the payload you can send.




And, of course, check out all the SAP Conversational AI tutorials.

 
6 Comments