api – Xenioo Wed, 02 Dec 2020 15:51:27 +0000 en-US hourly 1 https://wordpress.org/?v=5.5.3 /wp-content/uploads/2018/09/cropped-xenioo-badge-32x32.png api – Xenioo 32 32 LEZIONE #9: usare il Cloud Scripting per modifidare il chatbot durante l’esecuzione /cloud-scripting-esecuzione-chatbot/ /cloud-scripting-esecuzione-chatbot/#respond Fri, 08 Dec 2017 17:37:42 +0000 https://www.xenioo.com/?p=556 Now that we have learned how to call external API services and use the results in our chatbot, we can step a little further and alter the API results to create completely new content. In order to do so, in this lesson we are going to use Xenioo’s Cloud Scripting Action, and directly change and create content dynamically. You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot ...

Read MoreLEZIONE #9: usare il Cloud Scripting per modifidare il chatbot durante l’esecuzione

The post LEZIONE #9: usare il Cloud Scripting per modifidare il chatbot durante l’esecuzione appeared first on Xenioo.

]]>
Now that we have learned how to call external API services and use the results in our chatbot, we can step a little further and alter the API results to create completely new content. In order to do so, in this lesson we are going to use Xenioo’s Cloud Scripting Action, and directly change and create content dynamically.

You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example bot into your account for playback and testing. Let’s start!

YouTube Video

An artist lookup service

For this example, we’re going to build a very simple artist lookup service. To do so, we’ll be using the iTunes public search API that can be found here. The API is very easy to use and has a good amount of parameters.
First we are going to use an Input Action to get the artist’s name from the user and then the API Service Action to retrieve the data and store it in a variable.

This time the service will reply with a standard 500 error when no artist is found: to handle this, we will use a Variable Switch Operation to redirect the chat flow to another interaction whenever the user submits an artist that does not exist. If the call is successful, we will store the results into a Xenioo variable.

Multiple Results

Sometimes API calls will return complex results that are difficult to handle with a single variable. The call we are using returns a complex object with multiple information, so a simple variable would not suffice. Furthermore, to make our example more complex, we would like to display the results in a carousel, with multiple cards for multiple collections or albums. The general idea is to let the user say the name of an artist, and display the latest two albums found.

To do so, we need to retrieve the results, as we are doing, and then split them into multiple variables that can be assigned to our cards properties: an easy job for Xenioo’s Cloud Script Action.

Let’s Rock

Simply put, Xenioo Cloud Script Action will execute standard JavaScript code on Xenioo’s cloud servers. The Xenioo JavaScript runtime has all of the usual JavaScript goodies, and then some: each script action can access Xenioo global conversation, user and messaging objects. This means that at any point, you can alter the conversation state, add or remove variables and generally control the flow by pure coding.
Going back to our artist lookup, what we need to do now is to get the API result variable, transform the JSON into a real JavaScript object and create as many variables as required with all the values we need. Once we know the iTunes API model it is just a matter of a couple of lines of code.

Once we have all the variables we need we can create a Carousel Action and assign them to all the properties we want to fill. The title of the carousel can be the Album title, the subtitle can be the track name and the image can be the Album art.

Putting it all together

Once all our components are in place, we’re ready to give our bot a test run. Submit your favorite artist and see how Xenioo automatically handles everything to deliver our result. Also, take a moment to look at how simple our design is for such a complex result!

In this lesson we’ve learned how to use Xenioo’s Cloud Script Action to manipulate data and API results to create a simple lookup service.

You can find this chatbot in the Templates section of your Xenioo account. From there you can easily restore the chabot to
to further experiment and learn more.

The post LEZIONE #9: usare il Cloud Scripting per modifidare il chatbot durante l’esecuzione appeared first on Xenioo.

]]>
/cloud-scripting-esecuzione-chatbot/feed/ 0
TUTORIAL #9: Using Cloud Scripting to drive chatbot results /using-cloud-scripting/ /using-cloud-scripting/#respond Fri, 08 Dec 2017 17:37:42 +0000 https://www.xenioo.com/?p=556 Now that we have learned how to call external API services and use the results in our chatbot, we can step a little further and alter the API results to create completely new content. In order to do so, in this lesson, we are going to use Xenioo’s Cloud Scripting Action, and directly change and create content dynamically. You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot ...

Read MoreTUTORIAL #9: Using Cloud Scripting to drive chatbot results

The post TUTORIAL #9: Using Cloud Scripting to drive chatbot results appeared first on Xenioo.

]]>
Now that we have learned how to call external API services and use the results in our chatbot, we can step a little further and alter the API results to create completely new content.

In order to do so, in this lesson, we are going to use Xenioo’s Cloud Scripting Action, and directly change and create content dynamically.

You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example bot into your account for playback and testing. Let’s start!

YouTube Video

An artist lookup service

For this example, we’re going to build a very simple artist lookup service.

To do so, we’ll be using the iTunes public search API that can be found here. The API is very easy to use and has a good amount of parameters.

First we are going to use an Input Action to get the artist’s name from the user and then the API Service Action to retrieve the data and store it in a variable.

This time the service will reply with a standard 500 error when no artist is found: to handle this, we will use a Variable Switch Operation to redirect the chat flow to another interaction whenever the user submits an artist that does not exist. If the call is successful, we will store the results into a Xenioo variable.

Multiple Results

Sometimes API calls will return complex results that are difficult to handle with a single variable. The call we are using returns a complex object with multiple information, so a simple variable would not suffice. Furthermore, to make our example more complex, we would like to display the results in a carousel, with multiple cards for multiple collections or albums. The general idea is to let the user say the name of an artist, and display the latest two albums found.

To do so, we need to retrieve the results, as we are doing, and then split them into multiple variables that can be assigned to our cards properties: an easy job for Xenioo’s Cloud Script Action.

Let’s Rock

Simply put, Xenioo Cloud Script Action will execute standard JavaScript code on Xenioo’s cloud servers.

The Xenioo JavaScript runtime has all of the usual JavaScript goodies, and then some: each script action can access Xenioo global conversation, user and messaging objects. This means that at any point, you can alter the conversation state, add or remove variables and generally control the flow by pure coding.

Going back to our artist lookup, what we need to do now is to get the API result variable, transform the JSON into a real JavaScript object and create as many variables as required with all the values we need.

Once we know the iTunes API model it is just a matter of a couple of lines of code.

Once we have all the variables we need we can create a Carousel Action and assign them to all the properties we want to fill.

The title of the carousel can be the Album title, the subtitle can be the track name and the image can be the Album art.

Putting it all together

Once all our components are in place, we’re ready to give our bot a test run.

Submit your favorite artist and see how Xenioo automatically handles everything to deliver our result. Also, take a moment to look at how simple our design is for such a complex result!

In this lesson, we’ve learned how to use Xenioo’s Cloud Script Action to manipulate data and API results to create a simple lookup service.

As with all our lessons, you can find the chatbot sample in your Xenioo account so that you can import it to further experiment and learn.

The post TUTORIAL #9: Using Cloud Scripting to drive chatbot results appeared first on Xenioo.

]]>
/using-cloud-scripting/feed/ 0
TUTORIAL #8: Integrating external API services /integrating-external-api-services/ /integrating-external-api-services/#respond Wed, 06 Dec 2017 14:22:39 +0000 https://www.xenioo.com/?p=532 Now that we’ve learned all the basic aspects of the Xenioo chat flow design, we’re ready to further extend our chatbot by reaching out to external services. In this lesson we will learn how to call an external API service, extract specific data from the results and display it in the chatflow. You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example ...

Read MoreTUTORIAL #8: Integrating external API services

The post TUTORIAL #8: Integrating external API services appeared first on Xenioo.

]]>
Now that we’ve learned all the basic aspects of the Xenioo chat flow design, we’re ready to further extend our chatbot by reaching out to external services.

In this lesson we will learn how to call an external API service, extract specific data from the results and display it in the chatflow.

You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example bot into your account for playback and testing. Let’s start!

YouTube Video

Adding the API Service

Besides service specific actions (like MailChimp and SendGrid Actions), Xenioo provides a generic, multipurpose API Action that we can use to call an external service.

To add a new API integration, we just need to select an interaction and click on “Add Action”. In the Available Actions dialog, under the Integration tab, select “Call API Service”.

The new action will then be added to your interaction ready to be configured.

To keep this example simple, we’re going to skip services with a sign-up and API key and go straight for a public, immediate one.

We found Pokèapi: a free public API endpoint that can reply to a RESTful GET call with details about a named Pokémon. A standard GET call to something like http://pokeapi.co/api/v2/pokemon/pikachu will return a full JSON with details about Pikachu and its abilities.

How awesome is that? Let’s use it!

As you see, besides specifying the service full request URL, we can also select a property to be extracted from the resulting JSON and a variable where we want the value to be stored.

Notice how the JSON property is fully specified based on the model structure: Xenioo is going to extract the object at index zero of the abilities collection and read the property name of the sub-object ability.

Making it dynamic

The action we have just configured is going to retrieve the data about our Pokémon but it will always be the same.

We want the user to tell us what Pokémon to search, and dynamically display our results. To do so, we need to place a Generic Input Action like we’ve already configured in our previous lessons and make our call dynamic, using variables.

We will utilise the user input in our API call so that each call will be based on what the user says.

The important bit here is the service reply: a fully compliant RESTful request will usually reply with a 404 code (Not Found) as the requested record is not found.

This is not always the case however, and Xenioo allows you to fully control it by just using a built-in variable called ‘last_api_message’. By checking the contents of this variable after the API call, we can tell the user that a Pokémon does not exist, or display its abilities.

There we go! After setting up our interactions and personalizing the reply interactions, we’re ready to test drive our Pokémon look-up chatbot.

Sync or Async

API Calls may take a while to complete as some services may be slow or congested.

Xenioo’s approach to an API call is two-fold: if your API call has no child operations, the call will always be done asynchronously. If the API call has at least one child operation, the call will always be synchronous.

In the first case, the chatbot conversation will move forward while Xenioo completes the API call while in the second case, the conversation will hold until Xenioo has completed the API call.

In this lesson we’ve learned how to implement an API call to an external server and use the call results in our chatbot conversation.

As with all our lessons, you can find the chatbot sample in your Xenioo account so that you can import it to further experiment and learn.

The post TUTORIAL #8: Integrating external API services appeared first on Xenioo.

]]>
/integrating-external-api-services/feed/ 0
LEZIONE #8: integrare servizi esterni attraverso chiamate API restful /integrazione-servizi-api-rest/ /integrazione-servizi-api-rest/#respond Wed, 06 Dec 2017 14:22:39 +0000 https://www.xenioo.com/?p=532 Now that we’ve learned all the basic aspects of the Xenioo chat flow design, we’re ready to further extend our chatbot by reaching out to external services. In this lesson we will learn how to call an external API service, extract specific data from the results and display it in the chatflow. You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example ...

Read MoreLEZIONE #8: integrare servizi esterni attraverso chiamate API restful

The post LEZIONE #8: integrare servizi esterni attraverso chiamate API restful appeared first on Xenioo.

]]>
Now that we’ve learned all the basic aspects of the Xenioo chat flow design, we’re ready to further extend our chatbot by reaching out to external services. In this lesson we will learn how to call an external API service, extract specific data from the results and display it in the chatflow.

You can follow our lesson directly from the video below. At the end of the post you will find a Xenioo bot file that simply restores the example bot into your account for playback and testing. Let’s start!

YouTube Video

Adding the API Service

Besides service specific actions (like MailChimp and SendGrid Actions), Xenioo provides a generic, multipurpose API Action that we can use to call an external service. To add a new API integration, we just need to select an interaction and click on “Add Action”. In the Available Actions dialog, under the Integration tab, select “Call API Service”. The new action will then be added to your interaction ready to be configured.

To keep this example simple, we’re going to skip services with a sign-up and API key and go straight for a public, immediate one. We found Pokèapi: a free public API endpoint that can reply to a RESTful GET call with details about a named Pokémon. A standard GET call to something like http://pokeapi.co/api/v2/pokemon/pikachu will return a full JSON with details about Pikachu and its abilities..how awesome is that? Let’s use it!

As you see, besides specifying the service full request url, we can also select a property to be extracted from the resulting JSON and a variable where we want the value to be stored. Notice how the JSON property is fully specified based on the model structure: Xenioo is going to extract the object at index zero of the abilities collection and read the property name of the sub-object ability.

Making it dynamic

The action we have just configured is going to retrieve the data about our Pokémon but it will always be the same. We want the user to tell us what Pokémon to search, and dynamically display our results. To do so, we need to place a Generic Input Action like we’ve already configured in our previous lessons and make our call dynamic, using variables. We will utilise the user input in our API call so that each call will be based on what the user says.

The important bit here is the service reply: a fully compliant RESTful request will usually reply with a 404 code (Not Found) as the requested record is not found. This is not always the case however, and Xenioo allows you to fully control it by just using a built-in variable called ‘last_api_message’. By checking the contents of this variable after the API call, we can tell the user that a Pokémon does not exist, or display its abilities.

There we go! After setting up our interactions and personalizing the reply interactions, we’re ready to test drive our Pokémon look-up chatbot.

Sync or Async

API Calls may take a while to complete as some services may be slow or congested. Xenioo’s approach to an API call is two-fold: if your API call has no child operations, the call will always be done asynchronously. If the API call has at least one child operation, the call will always be synchronous. In the first case, the chatbot conversation will move forward while Xenioo completes the API call while in the second case, the conversation will hold until Xenioo has completed the API call.

In this lesson we’ve learned how to implement an API call to an external server and use the call results in our chatbot conversation.

You can find this chatbot in the Templates section of your Xenioo account. From there you can easily restore the chabot to
to further experiment and learn more.

The post LEZIONE #8: integrare servizi esterni attraverso chiamate API restful appeared first on Xenioo.

]]>
/integrazione-servizi-api-rest/feed/ 0