Aller au contenu principal

External Engine

In questa sezione


Request

{
"userQuestion": {
"userId": "userId",
"botId": "botId",
"conversationId": null,
"currentUrl": "www.google.com",
"questionId": -1,
"command": null,
"callType": "standard",
"inputMode": "keyboard",
"source": "text_landscape",
"sourceType": "web",
"disableFieldHistory": false,
"applicationContext": null,
"wsBasePath": null,
"question_text": "Ciao"
},
"previousStepResults": [
{
"intentId": 123,
"intentName": "Ciao",
"questionText": "Ciao",
"answer": {
"answerText": "Ciao a te",
"answerId": 1234
},
"externalId": "id"
}
],
"history": [
{
"userQuestion": "Hey bot",
"botMessageText": "Hey user"
}
],
"uuid": "b91f097b-f5f7-4825-be1d-1112a4f2c3ca"
}

Details

UserQuestion

userQuestion is the question from the user - will always be present

FieldDescriptionType
userIduser idstring
botIdbot id identifierstring
sourceTypecustom app name (not to be confused with source)string
conversationIdconversation id (first call: null)int
currentUrlurl where bot is integratedstring
question_texttext to send (required) Max lenght: 1000string
questionIdquestion id of clicked option (-1 default)int
commandcommand code of clicked option (if present) see tablestring
inputModeinput mode see tablestring
sourcesource type see tablestring
callTypecall type (standard or sandbox for sandbox mode)string
optionTypeoption type of clicked option see tablestring
applicationContextapplication context (used for targeted answers)string
disableFieldHistoryfor form answers, if true, field suggestions from conversation history are disabledstring
wsBasePathurl base for Algho Forms (optional) If present, it will be used to compose the final url by combining it with the relative one saved on the forms/fields.string
uuidthe UUID for webhook response (optional). More details in the Webhook section below.string

History

history is a list of objects containing the messages of the conversation

PreviousStepResults

previousStepResults are the results from the previous pipeline step (may be null or empty)

FieldDescriptionTypeOptional
intentIdthe intent idlongyes
intentNamethe intent namestringyes
questionTextthe question textstringno
answercontains the answer text and the optional answer idobject-
externalIdthe stored external id for the intentstringyes

Response

{
"interruptPipeline": true,
"results": [
{
"intentId": 123,
"intentName": "Ciao",
"questionText": "Ciao",
"answer": {
"answerText": "Ciao a te",
"answerId": 1234
},
"externalId": "id"
}
],
"answers": [
{
"answerId": "106049",
"answerText": "Hi",
"answerType": "QA"
}
]
}

Details

  • interruptPipeline will interrupt the pipeline if set as true. If any answers are present they will be prompted to the user
  • results will be used in case of uninterrupted pipeline, passing them to the next step
  • answers will be set as answers to the user. It's advisable to use answers with interruptPipeline set as true or results with interruptPipeline set as false.

The last answer of the answers list may start a dynamic form (refer to its documentation for more details) using a nextQuestion:

{
"answerText": "Answer starting a dynamic form",
"answerType": "QA",
"nextQuestions": [
{
"label": "Dynamic form name",
"nextQuestionType": "DYNAMIC_FORM",
"url": "https://www.google.it",
"questionText": "Dynamic form name"
}
]
}

Answers

FieldDescriptionType
answerTextanswer text in html (always mandatory)string
answerIdanswer id (optional)string
mediamedia url (optional)string
mediaTypemedia type (optional) see tablestring
answerTypeanswer type see tablestring
payloadCustom command (used for browser automation, voip commands)string
first *if this is the first answer (mandatory in asynchronous mode). Check the Webhook section below.boolean
last *if this is the last answer (mandatory in asynchronous mode). Check the Webhook section below.boolean
index *the order of this answer (0-based) (mandatory in asynchronous mode). Check the Webhook section below.integer

AnswerType ENUM

TypeNameDescription
QAAnsweranswer found in the knowledge base
QBQuibblecircumstance answers for questions to which the chatbot has no answer

MediaType ENUM

TypeDescription
linklink url
iframeurl which should be shown in an iframe
imgimage url
videovideo (youtube, vimeo, embedded video)
fileurl or base64 file
qrcodeurl to qr code image file
smart_document_accessSDA Document

WEBHOOK

If the request payload contains the uuid field, you MAY provide paragraphs asynchronously via webhooks.

In order to do so, respond to the request with a response having this body:

{
"asyncResponse": true
}

At this point, the uuid received in the request will be enabled to receveing asynchronously answers.

For each paragraph, call the following endpoint in POST:

https://composer.alghoncloud.com/api/conversate_item/webhook/{uuid}

where the uuid is the string received in the request.

Any request with a wrong / unrecognized uuid will be dropped silently.

The body contains a single answer (with the same structure documented above), with the addition of 3 new fields:

  • first, boolean, which indicates that this is the first answer
  • last, boolean, which indicates that this is the last answer
  • index, integer, which indicates the order of the answer itself (0-based)

Those 3 new fields are mandatory and MUST be present in the response payload.

If one of them is missing then the API will respond with status code 4xx.

On the user interface, a loading spinner will be displayed until the response where "last":true is received.

EXAMPLES
{
"answerText": "<p>First answer</p>",
"answerType": "QA",
"first": true,
"last": false,
"index": 0
}
{
"answerText": "<p>Second answer</p>",
"answerType": "QA",
"first": false,
"last": false,
"index": 1
}
{
"answerText": "<p>Last answer</p>",
"answerType": "QA",
"mediaType": "img",
"media": "https://picsum.photos/200/300",
"first": false,
"last": true,
"index": 2
}

It is also possible to call a dynamic form on the answer with "last":true. Refer to the relevant documentation.

{
"answerText": "<p>Starting form.</p>",
"answerType": "QA",
"nextQuestions": [{
"nextQuestionType": "DYNAMIC_FORM",
"url": "http://my.dinamic.form/endpoint"
}],
"first": true,
"last": true,
"index": 0
}

NOTES:

  • the uuid will NOT be available immediately;
  • the uuid will be available a few milliseconds after the external engine has responded to Algho;
  • the external engine must take care of the order in which the paragraphs are presented to the user (via the index field). Before presenting them to the user, Algho will apply text-to-speech, lip-sync, ect.
  • the uuid will remain valid for 2 minutes after the last successful request received (each successful request refreshes the decay timer to 2 minutes);
  • the uuid will be terminated as soon as a request with an answer containing "last":true is received and further requests for that uuid will be dropped.