Class AIAgent
Facade for the AI Agent AI services, such as Translation, Statistics, Sentiment analysis, backed by calls to Public Cloud providers
Namespace: SuperOffice.CRM.Services
Assembly: SuperOffice.Services.dll
Syntax
public class AIAgent : AgentBase<IAIAgent>, IDisposable, IAIAgent, IAgent
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
Constructors
AIAgent()
Facade for the AI Agent AI services, such as Translation, Statistics, Sentiment analysis, backed by calls to Public Cloud providers
Declaration
public AIAgent()
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
Methods
ClearChatbotTurns(String)
Clears the stored history of chat messages for a given chat_id. Chat_id is usually derived from soproto + current id, but could also be arbitrary name
Declaration
public void ClearChatbotTurns(string chatId)
Parameters
Type | Name | Description |
---|---|---|
String | chatId | identifies this chat = arbitrary name (e.g. user-defined) or the soprotocol + id (e.g. ticket-123, contact-43, diary) |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
CreateTextForAppointment(AppointmentEntity, String)
Generate agenda text for an appointment based on appointment's company category, title, person, etc.
Declaration
public string CreateTextForAppointment(AppointmentEntity appointment, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
AppointmentEntity | appointment | The appointment object to generate text for. |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | Agenda text in markdown format |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
DetectLanguage(String)
Given a (reasonably short) text, detect the language it is written in
Declaration
public string DetectLanguage(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to be analyzed; there may be a cost-per-character so do not send a book here |
Returns
Type | Description |
---|---|
String | ISO Language code, such as NO, US, ES, FR |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
DetectSentiment(String)
Detect the sentiment of a (reasonably short) text. Sentiment analysis may cause a translation to be made, since sentiment analysis only supports a limited set of languages
Declaration
public Sentiment DetectSentiment(string text)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to be analyzed |
Returns
Type | Description |
---|---|
Sentiment | The sentiment information: score (-100 to +100) and confidence |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
ExpandText(String, Int32, String)
Generate a longer version of a text
Declaration
public string ExpandText(string text, int percentBigger, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to embiggen |
Int32 | percentBigger | How much to embiggen. |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | Expanded version of the text |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetChatbotPromptSuggestions(String, String, Int32)
Return one or more suggested prompts as actions to display in an empty chat window
Declaration
public ChatbotTurn GetChatbotPromptSuggestions(string isoLangCode, string soProtocol, int currentId)
Parameters
Type | Name | Description |
---|---|---|
String | isoLangCode | ISO2 Language code ('en', 'no', 'de'...) for suggestions in response |
String | soProtocol | Context for suggestions ('contact.main.activities') |
Int32 | currentId | current company/person/project id - used for context in suggestions |
Returns
Type | Description |
---|---|
ChatbotTurn | Contains zero or more BotActions, and welcome message in Bot response |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetChatbotResponse(String, String, String, String, ChatbotTurn[], String)
Return a chatbot response given prompt and previous turns. Stores the new turn in the history for the chatId
Declaration
public ChatbotTurn GetChatbotResponse(string chatId, string isoLangCode, string userPrompt, string displayValue, ChatbotTurn[] previousTurns, string apiUrl)
Parameters
Type | Name | Description |
---|---|---|
String | chatId | identifies this chat = arbitrary name (e.g. user-defined) or the soprotocol + id (e.g. ticket-123, contact-43, diary) |
String | isoLangCode | ISO2 Language code ('en', 'no', 'de'...) for suggestions in response |
String | userPrompt | User question for chatbot |
String | displayValue | User question for display - optional - null = use userPrompt |
ChatbotTurn[] | previousTurns | Chat history - all previous turns in chronological order |
String | apiUrl | CRM API endpoint URL for chatbot to make callbacks to. 'https://example.com/superoffice/api/' |
Returns
Type | Description |
---|---|
ChatbotTurn | Returns new turn that client can append to its local history. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetChatbotTurns(String)
Returns stored history of chat messages for a given chat_id. Chat_id is usually derived from soproto + current id, but could also be arbitrary name.
Declaration
public ChatbotTurn[] GetChatbotTurns(string chatId)
Parameters
Type | Name | Description |
---|---|---|
String | chatId | identifies this chat = arbitrary name (e.g. user-defined) or the soprotocol + id (e.g. ticket-123, contact-43, diary) |
Returns
Type | Description |
---|---|
ChatbotTurn[] | Array containing zero or more turns. If you got zero turns, call GetChatbotPromptSuggestions to get an initial turn from the bot. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetSummarizeContactPrompt(Int32, Int32, String, String)
Return the prompt used to get a short summary of the activities on a contact. Does not call the chatbot for a response. Used for transfering a summary to a chat session.
Declaration
public ChatbotTurn GetSummarizeContactPrompt(int contactId, int numSentences, string summary, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | contactId | Contact id to summarize |
Int32 | numSentences | Length of summary |
String | summary | Chatbot's summary of the contact activities |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
ChatbotTurn | Display text and Prompt used to generate a short summary of the activities on a contact. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetSummarizeSalePrompt(Int32, Int32, String, String)
Return the prompt used to get a short summary of the activities on a sale. Does not call the chatbot for a response. Used for transfering a summary to a chat session.
Declaration
public ChatbotTurn GetSummarizeSalePrompt(int saleId, int numSentences, string summary, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | saleId | Sale id to summarize |
Int32 | numSentences | Length of summary |
String | summary | Chatbot's summary of the sale activities |
String | isoLangCode | Language returned text should be in |
Returns
Type | Description |
---|---|
ChatbotTurn | Display text and Prompt used to generate a short summary of the activities on a sale. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetSummarizeTicketPrompt(Int32, Int32, String, String)
Return the prompt used to get a short summary of the messages on a ticket. Does not call the chatbot for a response. Used for transfering a summary to a chat session.
Declaration
public ChatbotTurn GetSummarizeTicketPrompt(int ticketId, int numSentences, string summary, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | ticketId | Ticket id to summarize |
Int32 | numSentences | Length of summary |
String | summary | Chatbot's summary of the ticket |
String | isoLangCode | Language returned text should be in |
Returns
Type | Description |
---|---|
ChatbotTurn | Display text and Prompt used to generate a short summary of the messages on a ticket. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GetTrainingStatus()
Calling the HugoAI endpoint to fetch the current training status.
Declaration
public CategorizationStatusResponse GetTrainingStatus()
Returns
Type | Description |
---|---|
CategorizationStatusResponse | Carrier to describe the current status of HugoAI categorization |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
GuessCategory(Int32)
Given a ticket's id, guess the ticket category it should be placed in. Currently this is based on the first message in the ticket
Declaration
public int GuessCategory(int ticketId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | ticketId | Id of ticket to guess category for |
Returns
Type | Description |
---|---|
Int32 | Suggested ticket category ID |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
RephraseText(String, AiTextStyle, String)
Generate a new version of a text
Declaration
public string RephraseText(string text, AiTextStyle style, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to transform |
AiTextStyle | style | New style to transform text into (Rephrase, Correct, Casual, Formal) |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | New version of the text |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
SummarizeContact(Int32, Int32, String)
Generate a short summary of the activities on a contact
Declaration
public string SummarizeContact(int contactId, int numSentences, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | contactId | Contact id to summarize |
Int32 | numSentences | Length of summary |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | Short summary of the activities on a contact - in HTML. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
SummarizeSale(Int32, Int32, String)
Generate a short summary of the activities on a sale
Declaration
public string SummarizeSale(int saleId, int numSentences, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | saleId | Sale id to summarize |
Int32 | numSentences | Length of summary |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | Short summary of the activities on a sale - in HTML. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
SummarizeText(String, Int32, String)
Generate a short summary of a text
Declaration
public string SummarizeText(string text, int percentSmaller, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to summarize |
Int32 | percentSmaller | How much to shorten. |
String | isoLangCode | Language returned text should be in. Blank = do not specify language. |
Returns
Type | Description |
---|---|
String | Short summary of the text |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
SummarizeTicket(Int32, Int32, String)
Generate a short summary of the messages on a ticket
Declaration
public string SummarizeTicket(int ticketId, int numSentences, string isoLangCode)
Parameters
Type | Name | Description |
---|---|---|
Int32 | ticketId | Ticket id to summarize |
Int32 | numSentences | Length of summary |
String | isoLangCode | Language returned text should be in |
Returns
Type | Description |
---|---|
String | Short summary of the messages on a ticket - in HTML. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
TrainCategoryGuesser(Int32, Int32, Int32)
The category guesser training API will be called with an array of CategorizationTrainingItem during the (background, Batch) execution of this call
Declaration
public string TrainCategoryGuesser(int selectionId, int maxItems, int maxTextLength)
Parameters
Type | Name | Description |
---|---|---|
Int32 | selectionId | Id of selection of tickets, to retrieve training data from |
Int32 | maxItems | Maximum number of tickets to retrieve data from |
Int32 | maxTextLength | Maximum length of PlainTextBody or any other large text, truncated to nearest word boundary |
Returns
Type | Description |
---|---|
String | Placeholder for result... should this be a BatchTaskId? maybe not useful? |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
Translate(String, String)
Translate a text from one language to another. Language of the text is automatically detected.
Declaration
public string Translate(string text, string targetLanguage)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to be translated. Language of the text is automatically detected. |
String | targetLanguage | ISO Language code (such as FR) to translate the text into |
Returns
Type | Description |
---|---|
String | Translated text |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}
TranslateEntity(String, Int32, String)
Retrieve, format and translate text for an entity to a specified language
Declaration
public string TranslateEntity(string entityName, int entityId, string targetLanguage)
Parameters
Type | Name | Description |
---|---|---|
String | entityName | Name of entity to get the text to be translated; eg., 'ticketMessage' |
Int32 | entityId | Identifier for the entity to get text to be translated |
String | targetLanguage | ISO Language code (such as FR) to translate the text into |
Returns
Type | Description |
---|---|
String | Translated text |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (AIAgent agent = new AIAgent())
{
// call methods on agent here...
}
}