Back-end integration with an API plugin

Last updated last month

Enrich your conversational platform with data available from your services.

Introduction

Who is this tutorial for?

What are we trying to teach?

Setting up

You can add the API Plugin by clicking creating a new action and then clicking API.

Let's start by selecting the request method for our endpoint. In this example we are going to cover the a post request but you are able to choose from get, post and delete.

Now we can continue by setting up our query params, these translate into a query string on your URL. e.g: https://your-url.com?source=Chatlayer

You can only define a request body when your request method is POST or DELETE

In the query we have covered the text type but you actuality can choose three different types inside both your body and query. In the body example we are going to cover all types.

post
Your example API

http://your-url.com/
?source={source}
This is an example of how your API you should respond. Check the response tab for an example on how to structure your responses to successfully utilise all the strengths of this plugin.
Request
Response
Query Parameters
source
required
string
Source of where the request is being called
Body Parameters
administration
optional
string
ID of the administration dialogstate
user
required
object
User object containing firstname and nickname
200: OK
All three possible responses combined.
{
// Session object sets namespace.variable to value 123
"session": {
"namespace": "namespace",
"data": {
"variable": "123"
}
},
// Messages are being sent to the user.
"messages": [
{
"type": "text",
"config": {
"textMessages": [{ "text": "random message 1" }, { "text": "random message 2" }]
}
}
],
// Navigates to the next dialogstate.
"action": {
"nextDialogstate": "dialogstate-123-abc"
}
}