sales_assistant_v2/invoke/v1
Last updated
Last updated
Here is the basic format of a request:
POST /internal/v1/businesses/{business_id}/ai/sales_assistant_v2/invoke/v1
Headers:
Content-Type: application/json
x-api-key: YOUR_API_KEY
Body:
{
"context": {
"agentDescriptorId": "example-agent",
},
"inputEvents": [
{
"messageEvent": {
"role": "USER",
"content": {
"textContent": "Example input text"
}
}
}
]
}
Here is a real world example that invokes the Sales Assistant V2:
Scenario:
The customer enters a web chat window and the bot immedatiely responds with a default welcome message. The bot then begins to assist the customer.
Web chat conversation:
Bot: Welcome to my store! How can I help? # This is automatically generated response
Customer: Do you offer free shipping?
API Request:
{
"context": {
"agentDescriptorId": "018e7dc6-d9f8-48aa-1751-b57fdce7403e", // Not a real agent_descriptor_id
},
"inputEvents": [
{
"messageEvent": {
"role": "ASSISTANT",
"content": {
"textContent": "Welcome to my store! How can I help?"
}
}
},
{
"messageEvent": {
"role": "USER",
"content": {
"textContent": "Do you offer free shipping?"
}
}
}
]
}
API Response:
{
"response": {
"stateId": "018e7d88-792a-a9c3-b24b-b6e3055923fb",
"sessionId": "018e7d88-4bfa-0111-4540-7c4be2e7f494",
"responseEvents": [
{
"messageEvent": {
"role": "ASSISTANT",
"content": {
"textContent": {
"text": "We do offer free shipping on all orders over $50!"
}
}
}
},
{
"messageEvent": {
"role": "ASSISTANT",
"content": {
"textContent": {
"text": "Can I help you find a product?"
}
}
}
}
]
}
}
Assistant: We do offer free shipping on all orders over $50!
Assistant: Can I help you find a product?
Customer: Yes I want a pink dress for my daughters 10th birthday
API Request:
{
"context": {
"stateId": "018e7d88-792a-a9c3-b24b-b6e3055923fb", // Use the stateId from the previous response to continue the conversation
},
"input_events": [
{
"messageEvent": {
"role": "USER",
"content": {
"textContent": "Yes I want a pink dress for my daughters 10th birthday"
}
}
}
]
}
API Response:
{
"response": {
"stateId": "018e7dcc-3a0e-819f-7b10-6399b1a610d2",
"sessionId": "018e7d88-4bfa-0111-4540-7c4be2e7f494",
"responseEvents": [
{
"recommendationEvent": {
"products": [
{
"productId": "018c6302-ec34-02f2-cc2c-c5f1f38a7a03",
"title": "Pink dress size 10yrs",
"description": "The perfect pink dress for all Birthdays and events",
"url": "<url>",
"imageUrl": "<url>",
"price": 79.9,
"currency": "USD",
"facets": null,
"metadata": null
},
{
"productId": "018c39ce-db1b-48e1-1bca-d36601955c9c",
"title": "Connectly Signature Pink Dress",
"description": "This dress is made for 10 year olds to enjoy their birthdays and the only dress made by a chatbot company",
"url": "<url>",
"imageUrl": "<url>",
"price": 179.9,
"currency": "USD",
"facets": null,
"metadata": null
}
]
}
},
{
"messageEvent": {
"role": "ASSISTANT",
"content": {
"textContent": {
"text": "Do either of these dresses stand out to you?"
}
}
}
},
{
"messageEvent": {
"role": "ASSISTANT",
"content": {
"textContent": {
"text": "Does she also like purple?"
}
}
}
}
]
}
}
Assistant: Do either of these dresses stand out to you?
Assistant: Does she also like purple?
Conversation Continues...
The input events to pass to the customer. It is important to include all input events since the last call. For example: if there is an automated welcome message, it should be included as an assistant message.
System parameters for internal use only.
A successful response.