Connectly Documentation
  • 👋Welcome to Connectly.ai
  • 🚀Quick Start
    • Prerequisites
    • Authentication
    • Send WhatsApp template message
    • Send WhatsApp session message
  • 📣Campaigns
    • Campaign Sendout
      • Send Campaigns
  • 🤖Sofia AI
    • How to use Sofia AI?
    • Sofia AI API
      • Reference
        • Core Concepts
        • sales_assistant_v2/invoke/v1
  • 📱Message API
    • Message Service API
      • MessageService
        • Send template message
        • Send session message
      • Error codes
    • Webhook API
      • WebhookService
        • Create a webhook registration by event topic
        • Update an existing webhook registration by event topic
        • Get webhook registrations for business
        • Delete a webhook registration for business
      • Webhook Payload
        • Delivery Status Error Codes
        • Payload Media Types
  • 🤖Business Management
    • Business Management API
      • Template Management
        • Create a template
        • Get templates
      • Quality Signals
  • 📱Integrations
    • Integrations
      • WebEngage Integration
      • Message your customers on Zendesk through Connectly
      • Message your customer on Intercom through Connectly
    • [Alpha] Moengage
      • MessageService
        • Send Campaign via API
  • 📊Analytics
    • Analytics
      • [Alpha] Campaign report
      • Reports API
        • Webhooks configuration
  • 👀FAQ
  • Migrating WhatsApp Accounts
  • How to use time delay?
Powered by GitBook
On this page
  1. Sofia AI
  2. Sofia AI API
  3. Reference

sales_assistant_v2/invoke/v1

PreviousCore ConceptsNextMessage Service API

Last updated 1 year ago

🤖

InvokeSalesAssistantV2 makes a call to the Sales Assistant V2 API.

post

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...

Authorizations
Path parameters
input.businessIdstringRequired
Body
systemobjectOptional

System parameters for internal use only.

Responses
200
A successful response.
application/json
default
An unexpected error response.
application/json
post
POST /internal/v1/businesses/{input.businessId}/ai/sales_assistant_v2/invoke/v1 HTTP/1.1
Host: api.connectly.ai
x-api-key: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 228

{
  "context": {
    "state_id": "06a1d144-0de0-49e7-96c8-7bfc0fc1f657"
  },
  "inputEvents": [
    {
      "message_event": {
        "role": "USER",
        "content": {
          "text_content": {
            "text": "I want to buy my wife something festive for our christmas party?"
          }
        }
      }
    }
  ],
  "system": {}
}
{
  "response": {
    "stateId": "text",
    "sessionId": "text",
    "responseEvents": [
      {
        "messageEvent": {
          "role": "NA",
          "content": {
            "textContent": {
              "text": "text"
            },
            "audioContent": {
              "url": "text"
            }
          },
          "createdAt": "2025-05-15T13:29:20.875Z",
          "metadata": {}
        },
        "recommendationEvent": {
          "products": [
            {
              "productId": "text",
              "title": "text",
              "description": "text",
              "url": "text",
              "imageUrl": "text",
              "price": 1,
              "currency": "text",
              "facets": {},
              "metadata": {}
            }
          ]
        }
      }
    ]
  }
}