curl --request POST \
--url https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions \
--header 'Content-Type: application/json' \
--header 'asapp-api-id: <api-key>' \
--header 'asapp-api-secret: <api-key>' \
--data '
{
"query": "Hello, how can",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": "customer-x"
},
"timestamp": "2023-06-01T19:16:55.706Z"
}
}
'import requests
url = "https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions"
payload = {
"query": "Hello, how can",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": "customer-x"
},
"timestamp": "2023-06-01T19:16:55.706Z"
}
}
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({
query: 'Hello, how can',
message: {
text: 'Hello, I would like to upgrade my internet plan to GOLD.',
sender: {role: 'customer', externalId: 'customer-x'},
timestamp: '2023-06-01T19:16:55.706Z'
}
})
};
fetch('https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions', 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/autocompose/v1/conversations/{conversationId}/suggestions",
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([
'query' => 'Hello, how can',
'message' => [
'text' => 'Hello, I would like to upgrade my internet plan to GOLD.',
'sender' => [
'role' => 'customer',
'externalId' => 'customer-x'
],
'timestamp' => '2023-06-01T19:16:55.706Z'
]
]),
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/autocompose/v1/conversations/{conversationId}/suggestions"
payload := strings.NewReader("{\n \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\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/autocompose/v1/conversations/{conversationId}/suggestions")
.header("asapp-api-id", "<api-key>")
.header("asapp-api-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions")
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 \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"message": {
"id": "01BX5ZZKBKACTAV9WEVGEMMVS1"
},
"suggestions": [
{
"text": "Hello John, how can I help you?",
"templateText": "Hello {NAME}, how can I help you?",
"title": "Greeting"
}
],
"phraseCompletion": {
"text": "Hello, how can I help you?"
},
"autopilotMessage": {
"text": "Hello John, how can I help you?",
"templateText": "Hello {NAME}, how can I help you?",
"title": "Greeting",
"delaySeconds": 5,
"triggerAfterSeconds": 0
}
}{
"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"
}
}Generate suggestions
Get suggestions for the next agent message in the conversation.
There are several times when this should be called:
- when an agent joins the conversation,
- after a message is sent by either the customer or the agent,
- and as the agent is typing in the composer (to enable completing the agent’s in-progress message).
Optionally, add a message to the conversation.
curl --request POST \
--url https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions \
--header 'Content-Type: application/json' \
--header 'asapp-api-id: <api-key>' \
--header 'asapp-api-secret: <api-key>' \
--data '
{
"query": "Hello, how can",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": "customer-x"
},
"timestamp": "2023-06-01T19:16:55.706Z"
}
}
'import requests
url = "https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions"
payload = {
"query": "Hello, how can",
"message": {
"text": "Hello, I would like to upgrade my internet plan to GOLD.",
"sender": {
"role": "customer",
"externalId": "customer-x"
},
"timestamp": "2023-06-01T19:16:55.706Z"
}
}
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({
query: 'Hello, how can',
message: {
text: 'Hello, I would like to upgrade my internet plan to GOLD.',
sender: {role: 'customer', externalId: 'customer-x'},
timestamp: '2023-06-01T19:16:55.706Z'
}
})
};
fetch('https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions', 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/autocompose/v1/conversations/{conversationId}/suggestions",
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([
'query' => 'Hello, how can',
'message' => [
'text' => 'Hello, I would like to upgrade my internet plan to GOLD.',
'sender' => [
'role' => 'customer',
'externalId' => 'customer-x'
],
'timestamp' => '2023-06-01T19:16:55.706Z'
]
]),
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/autocompose/v1/conversations/{conversationId}/suggestions"
payload := strings.NewReader("{\n \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\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/autocompose/v1/conversations/{conversationId}/suggestions")
.header("asapp-api-id", "<api-key>")
.header("asapp-api-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.asapp.com/autocompose/v1/conversations/{conversationId}/suggestions")
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 \"query\": \"Hello, how can\",\n \"message\": {\n \"text\": \"Hello, I would like to upgrade my internet plan to GOLD.\",\n \"sender\": {\n \"role\": \"customer\",\n \"externalId\": \"customer-x\"\n },\n \"timestamp\": \"2023-06-01T19:16:55.706Z\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"message": {
"id": "01BX5ZZKBKACTAV9WEVGEMMVS1"
},
"suggestions": [
{
"text": "Hello John, how can I help you?",
"templateText": "Hello {NAME}, how can I help you?",
"title": "Greeting"
}
],
"phraseCompletion": {
"text": "Hello, how can I help you?"
},
"autopilotMessage": {
"text": "Hello John, how can I help you?",
"templateText": "Hello {NAME}, how can I help you?",
"title": "Greeting",
"delaySeconds": 5,
"triggerAfterSeconds": 0
}
}{
"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"
}
}Path Parameters
The identifier for a conversation.
^[A-Z0-9]+$Body
The parameters for getting suggestions for the next agent message.
A suggestions request with an optional message to add to the conversation
text the agent has already entered into the composer
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": "agent", "externalId": 123 },
"timestamp": "2021-11-23T12:13:14.555Z"
}Response
Successfully fetched suggestions for the conversation
Suggestions for next agent message
ID for the suggestions that were returned (to be used in analytics events)
Response for messages
Show child attributes
Show child attributes
{ "id": "01BX5ZZKBKACTAV9WEVGEMMVS1" }Show child attributes
Show child attributes
Completion of the phrase the agent is currently typing, to be displayed inline in the composer
Show child attributes
Show child attributes
Recommended message for the agent to autopilot send.
Show child attributes
Show child attributes
Was this page helpful?