Skip to Content
Technical Articles

You now must call chatbot APIs with OAuth – here’s how

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/train/v2/request and the method to POST.
  • 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.

 

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