curl --request POST \
--url https://api.sandbox.asapp.com/generativeagent/v1/analyze \
--header 'Content-Type: application/json' \
--header 'asapp-api-id: <api-key>' \
--header 'asapp-api-secret: <api-key>' \
--data '
{
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": 123
},
"timestamp": "2021-11-23T12:13:14.555Z"
},
"taskName": "UpgradePlan",
"inputVariables": {
"context": "Customer called to upgrade their current plan to GOLD",
"customer_info": {
"current_plan": "SILVER",
"customer_since": "2020-01-01"
}
},
"channelType": "digital"
}
'import requests
url = "https://api.sandbox.asapp.com/generativeagent/v1/analyze"
payload = {
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": 123
},
"timestamp": "2021-11-23T12:13:14.555Z"
},
"taskName": "UpgradePlan",
"inputVariables": {
"context": "Customer called to upgrade their current plan to GOLD",
"customer_info": {
"current_plan": "SILVER",
"customer_since": "2020-01-01"
}
},
"channelType": "digital"
}
headers = {
"asapp-api-id": "<api-key>",
"asapp-api-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'asapp-api-id': '<api-key>',
'asapp-api-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
conversationId: '01BX5ZZKBKACTAV9WEVGEMMVS0',
message: {
text: 'Hello, I would like to upgrade my internet plan to GOLD.',
sender: {role: 'customer', externalId: 123},
timestamp: '2021-11-23T12:13:14.555Z'
},
taskName: 'UpgradePlan',
inputVariables: {
context: 'Customer called to upgrade their current plan to GOLD',
customer_info: {current_plan: 'SILVER', customer_since: '2020-01-01'}
},
channelType: 'digital'
})
};
fetch('https://api.sandbox.asapp.com/generativeagent/v1/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.asapp.com/generativeagent/v1/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'conversationId' => '01BX5ZZKBKACTAV9WEVGEMMVS0',
'message' => [
'text' => 'Hello, I would like to upgrade my internet plan to GOLD.',
'sender' => [
'role' => 'customer',
'externalId' => 123
],
'timestamp' => '2021-11-23T12:13:14.555Z'
],
'taskName' => 'UpgradePlan',
'inputVariables' => [
'context' => 'Customer called to upgrade their current plan to GOLD',
'customer_info' => [
'current_plan' => 'SILVER',
'customer_since' => '2020-01-01'
]
],
'channelType' => 'digital'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"asapp-api-id: <api-key>",
"asapp-api-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.asapp.com/generativeagent/v1/analyze"
payload := strings.NewReader("{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("asapp-api-id", "<api-key>")
req.Header.Add("asapp-api-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.asapp.com/generativeagent/v1/analyze")
.header("asapp-api-id", "<api-key>")
.header("asapp-api-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.asapp.com/generativeagent/v1/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["asapp-api-id"] = '<api-key>'
request["asapp-api-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}"
response = http.request(request)
puts response.read_body{
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"messageId": "01BX5ZZKBKACTAV9WEVGEMMVS1"
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "400-01",
"message": "Bad request"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "401-01",
"message": "Unauthorized"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "403-01",
"message": "Forbidden Response"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "404-01",
"message": "Not Found"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "409-01",
"message": "Conflict"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "413-01",
"message": "Request Entity Too Large"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "422-01",
"message": "Unprocessable Entity"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "429-01",
"message": "Too Many Requests"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "503-01",
"message": "Service Unavailable"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "500-01",
"message": "Internal server error"
}
}Analyze conversation
Call this API to trigger GenerativeAgent to analyze and respond to a conversation.
This API should be called after a customer sends a message while not speaking with a live agent. The Bot replies will not be returned on this request; they will be delivered asynchronously via the webhook callback.
This API also adds an optional message field to create a message for a given conversation before triggering the bot replies. The message object is the exact same message used in the conversations API /message endpoint
curl --request POST \
--url https://api.sandbox.asapp.com/generativeagent/v1/analyze \
--header 'Content-Type: application/json' \
--header 'asapp-api-id: <api-key>' \
--header 'asapp-api-secret: <api-key>' \
--data '
{
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": 123
},
"timestamp": "2021-11-23T12:13:14.555Z"
},
"taskName": "UpgradePlan",
"inputVariables": {
"context": "Customer called to upgrade their current plan to GOLD",
"customer_info": {
"current_plan": "SILVER",
"customer_since": "2020-01-01"
}
},
"channelType": "digital"
}
'import requests
url = "https://api.sandbox.asapp.com/generativeagent/v1/analyze"
payload = {
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": 123
},
"timestamp": "2021-11-23T12:13:14.555Z"
},
"taskName": "UpgradePlan",
"inputVariables": {
"context": "Customer called to upgrade their current plan to GOLD",
"customer_info": {
"current_plan": "SILVER",
"customer_since": "2020-01-01"
}
},
"channelType": "digital"
}
headers = {
"asapp-api-id": "<api-key>",
"asapp-api-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'asapp-api-id': '<api-key>',
'asapp-api-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
conversationId: '01BX5ZZKBKACTAV9WEVGEMMVS0',
message: {
text: 'Hello, I would like to upgrade my internet plan to GOLD.',
sender: {role: 'customer', externalId: 123},
timestamp: '2021-11-23T12:13:14.555Z'
},
taskName: 'UpgradePlan',
inputVariables: {
context: 'Customer called to upgrade their current plan to GOLD',
customer_info: {current_plan: 'SILVER', customer_since: '2020-01-01'}
},
channelType: 'digital'
})
};
fetch('https://api.sandbox.asapp.com/generativeagent/v1/analyze', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.asapp.com/generativeagent/v1/analyze",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'conversationId' => '01BX5ZZKBKACTAV9WEVGEMMVS0',
'message' => [
'text' => 'Hello, I would like to upgrade my internet plan to GOLD.',
'sender' => [
'role' => 'customer',
'externalId' => 123
],
'timestamp' => '2021-11-23T12:13:14.555Z'
],
'taskName' => 'UpgradePlan',
'inputVariables' => [
'context' => 'Customer called to upgrade their current plan to GOLD',
'customer_info' => [
'current_plan' => 'SILVER',
'customer_since' => '2020-01-01'
]
],
'channelType' => 'digital'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"asapp-api-id: <api-key>",
"asapp-api-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sandbox.asapp.com/generativeagent/v1/analyze"
payload := strings.NewReader("{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("asapp-api-id", "<api-key>")
req.Header.Add("asapp-api-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sandbox.asapp.com/generativeagent/v1/analyze")
.header("asapp-api-id", "<api-key>")
.header("asapp-api-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.asapp.com/generativeagent/v1/analyze")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["asapp-api-id"] = '<api-key>'
request["asapp-api-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"conversationId\": \"01BX5ZZKBKACTAV9WEVGEMMVS0\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": 123\n },\n \"timestamp\": \"2021-11-23T12:13:14.555Z\"\n },\n \"taskName\": \"UpgradePlan\",\n \"inputVariables\": {\n \"context\": \"Customer called to upgrade their current plan to GOLD\",\n \"customer_info\": {\n \"current_plan\": \"SILVER\",\n \"customer_since\": \"2020-01-01\"\n }\n },\n \"channelType\": \"digital\"\n}"
response = http.request(request)
puts response.read_body{
"conversationId": "01BX5ZZKBKACTAV9WEVGEMMVS0",
"messageId": "01BX5ZZKBKACTAV9WEVGEMMVS1"
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "400-01",
"message": "Bad request"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "401-01",
"message": "Unauthorized"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "403-01",
"message": "Forbidden Response"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "404-01",
"message": "Not Found"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "409-01",
"message": "Conflict"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "413-01",
"message": "Request Entity Too Large"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "422-01",
"message": "Unprocessable Entity"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "429-01",
"message": "Too Many Requests"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "503-01",
"message": "Service Unavailable"
}
}{
"error": {
"requestId": "8e033668-9f1a-11ec-b909-0242ac120002",
"code": "500-01",
"message": "Internal server error"
}
}Body
The parameters for triggering the analysis and response to a conversation
Internal conversation identifier from ASAPP
"01BX5ZZKBKACTAV9WEVGEMMVS0"
The id associated with the connection where the responses should be sent to.
"97555020-0276-435f-8104-c378221ba292"
Name of the task to be used in the analysis
"UpgradePlan"
Input variables to be used as context in the analysis.
{
"call_context": "Customer called to upgrade their current plan to GOLD",
"customer_info": {
"current_plan": "SILVER",
"customer_since": "2020-01-01"
}
}Represents a single message within a conversation.
Show child attributes
Show child attributes
{
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": { "role": "customer", "externalId": 123 },
"timestamp": "2021-11-23T12:13:14.555Z"
}Channel type used by the current request (digital or voice)
digital, voice "digital"
Response
Successfully triggered the bot to analyze and respond to a conversation
Was this page helpful?