Interview.fetch() Oracle B2C Service Cloud REST API

Thanks must go to Oracle Intelligent Advisor guru and Intelligent-Advisor.com web site supporter AH for the idea for this post. This site has written many articles on the relatively new subject of the Interview Fetch capability. Here is a reminder of the basic principle. In the Hub, we can now place a Connection with a new type of Interview Extension. This represents an endpoint of some kind that can be called from an Interview Extension using the new method interview.fetch() of the interview object.

We’ve already seen some examples here on intelligent-advisor.com:

  1. Send Email with Fetch()
  2. Transcript Generation
  3. Using Promise in Fetch()

But this post is dedicated to another use of the interview.fetch concept. We will experiment using the Interview to query, update, insert or delete data into Oracle B2C Service aka Oracle Service Cloud aka RightNow. The details of the operations can of course be found in the online documentation for B2C Service.

Let’s look at the setup. We need a Connection in the Hub, pointing to a base URI that is common to all of the REST API endpoints. And we will add Basic Authentication details so that our call will actually be possible.

Now we can build our little interview. We are going to first add an entity to represent our clients. And then we can add the buttons to let us edit, insert, delete each one. Of course I’m cutting corners and doing bad things – I’m hard coding HTML id’s and the like. But I’m in a hurry (I have my 43rd Zoom call of the week in 15 minutes). But the idea is to demonstrate the principle of the Interview Connection :

The connection uses the basic root of the REST API version that we intend to use. Depending on the verb that is selected then various things are displayed.

Oracle B2C Service Cloud Example

The different buttons are of course going to call the REST API in different ways. Here is an example from the POST (to create a contact). The body includes the fields to be sent. The call also includes contentType which is required if there is a body. The relative Uri allows us to build on the root URL to create calls potentially to different objects or services.

var opts = {
			connectionName: "CONNECTIONNAME",
			relativeUri: "/contacts",
			method: "POST",
			contentType : "application/json",
			body: {
				"name": {
					"first": theContactFirst,
					"last": theContactLast
				}
			}
		}
		try {
			interview.fetch(opts)

And here is another example with the DELETE version, where the Id is the only item needed, with no body when calling Oracle B2C Service Cloud:

var opts = {
			connectionName: "YOURCONNECTION",
			relativeUri: "/contacts/" + theContactId,
			method: "DELETE"
		}
		try {
			interview.fetch(opts)

Of course the various variables in these two examples are the contents of the inputs on the Screen. So we can now experiment with the different items and view the responses. It demonstrates the usefulness both of the Oracle B2C Service (Oracle Service Cloud) REST API and the interview.fetch() capability of the Oracle Intelligent Advisor Hub / JavaScript API.

If you want the Zip Archive, just leave a note in the comments.

video

Richard Napier

Author: Richard Napier

Richard Napier joined Siebel Systems in 1999 and took up the role of managing the nascent Siebel University in Southern Europe. He subsequently was Director of Business Development and Education for InFact Group (now part of Business & Decisions) for 8 years. He now runs Intelligent Advisor IT Consulting OÜ. Owner of intelligent-advisor.com, he also is Co-Founder of the Siebel Hub.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Worldwide
Logo by Southpaw Projects LLC