Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert excerpt
_ExcerptVirtualAssistant
_ExcerptVirtualAssistant
nopaneltrue

...

  1. Get an API key for Vonage AI API. Ask Vonage to store this key in a custom configuration value for your account. For information about getting an API key for Vonage AI API, see Vonage AI Studio authentication.
  2. Create a virtual agent and configure the agent's conversation. Save the agent's ID and virtual number to use later. For information about creating a virtual agent, see Create a new Vonage AI Studio agent.
  3. Make a note of response parameters that your virtual agent can return. For information about response parameters, see Vonage AI Studio parameters.

The following visualization shows an interaction plan that routes interactions to a virtual agent, and collects data about the interaction:

...

In Interaction Definition, call the Vonage AI API to create a virtual agent session for this interaction. The URL for the Vonage AI API depends on your region. Replace *** within the Url element in the example later in this page with the URL for Vonage AI for the applicable region:

  • EMEA: studio-api-eu.ai.vonage.com
  • NAM: studio-api-us.ai.vonage.com

Provide the following parameters in the request element:

  • X-Vgai-Key. Either hardcode the API key for the Vonage AI API or get the value for this header from a custom configuration value in your account. For more information about using custom configuration values, see Using a custom configuration value in a Web Service Interface request
  • agent_id. The value for this body parameter is the ID for the virtual agent that you want to use for the session. You can get the agent's ID from Vonage AI Studio. For information about the agent's virtual number, see What are Vonage AI Studio agents?.

...

In the response element, store the session_id and session_start_time from the response in SessionId and SessionStartTime data sources respectively. Subsequent applets require these values.

<Body><![CDATA[
Code Block
languagexml
titleCaller Name
Interaction Definition
<ApiInteraction>
 { <Request>
 "agent_id": "65d9634bf3a2412eb16e7adf",
  "parameters": [
    {<!--Replace *** with the root of the URL of the Vonage AI API-->
    "name": "CALLER_NAME",<Url>https://***/flow/init</Url>
     "value": "$(Name)"
 <Method>POST</Method>
    <Headers>
  }   ] <Header>
}
]]></Body>

Store the session_id and session_start_time from the response in SessionId and SessionStartTime data sources respectively. Subsequent applets require these values.

Code Block
languagexml
titleInteraction Definition
<ApiInteraction>
  <Request>
    <Url>https://stairway.ai.vonage.com/flow/init</Url>
    <Method>POST</Method>
    <Headers>
      <Header><!--Include the API key for the Vonage AI API. Hardcode the key or store the value in a custom configuration value or data source. This example uses a custom configuration value.-->
        <Key>X-Vgai-Key</Key>
        <Value>#(api_key)</Value>
      </Header>
    </Headers>
    <Body>
 <Body><<!--Include the ID of the virtual agent using this session. Hardcode the key or store the value in a data source. This example hardcodes the value.-->
        <![CDATA[
        {
          "agent_id": "65d9634bf3a2412eb16e7adf"
        }      
        ]]><>
    </Body>
  </Request>
  <Response>
    <Type>JSON</Type>
    <ResponseCodeDestination>CreateSessionResponseCode</ResponseCodeDestination>
    <Fields>
<!--Store session_id and session_start_time from response in SessionId and SessionStartTime data sources.-->
      <Field>
        <Locator>session_id</Locator>
        <Destination>SessionId</Destination>
        <DataType>string</DataType>
      </Field>
      <Field>
        <Locator>session_start_time</Locator>
        <Destination>SessionStartTime</Destination>
        <DataType>string</DataType>
      </Field>
    </Fields>
  </Response>
</ApiInteraction>

You can also provide optional parameters as metadata. You must define these parameters in Vonage AI. For example, to provide the customer name, define a parameter in Vonage AI with the name CALLER_NAME, and then specify the following in your data connector:

Code Block
languagexml
titleCaller Name
<Body>
<!--Include optional parameters in the body element.-->
  <![CDATA[ 
    {
      "agent_id": "65d9634bf3a2412eb16e7adf",
      "parameters": [
    {
      "name": "CALLER_NAME",
      "value": "$(Name)"
    }
  ] 
  }
]]></Body>

For information about using a Data Connector applet, see Retrieving data from and sending data to a Web Service.

...

This applet transfers the interaction to a virtual agent within Virtual Assistant.In the Virtual Agent Supplier list, click Vonage AI.

Set Virtual Agent Number to the number of the same agent that you used to create the session. You can get this number from Vonage AI Studio. For information about the agent's virtual number, see What are Vonage AI Studio agents?

Set Vonage AI Session Id to the value of the SessionId data source collected by the Data Connector applet (Create virtual agent session). Example: For example, $(SessionId).

Transfer to a virtual agent

For information about the Virtual Agent applet, see Virtual Agent applet.

...

In Interaction Definition, call the Vonage AI API to request information about the virtual agent session. The URL for the Vonage AI API depends on your region. Replace *** within the Url element in the example later in this page with the URL for Vonage AI for the applicable region:

  • EMEA: studio-api-eu.ai.vonage.com
  • NAM: studio-api-us.ai.vonage.com

The response is always in JSON format, but the parameters, or fields, within the JSON response depend on your individual virtual agent's configuration. Store the parameters in a data source called params_list. Vonage AI Studio will contain the names of available response parameters.

Use the next Data Connector applet (Extract specific virtual agent data) to get values from required parameters in params_list.

Code Block
languagexml
titleInteraction Definition
<ApiInteraction>
  <Request>
<!--Replace *** with the root of the URL of the Vonage AI API-->
    <Url>https://stairway.ai.vonage.com***/insights/sessions/$(session id)?session_start_time=$(session start time)</Url>
    <Method>GET</Method>
    <Headers>
      <Header>
<!--Include the API key for the Vonage AI API. Hardcode the key or store the value in a custom configuration value or data source. This example uses a custom configuration value.-->
        <Key>X-Vgai-Key</Key>
        <Value>#(api_key)</Value>
      </Header>
    </Headers>
  </Request>
  <Response>
    <Type>JSON</Type>
    <ResponseCodeDestination>Session</ResponseCodeDestination>
		<Fields>
  		<Field>
<!--Store response parameters in a destination data source.-->
    		<Locator>params_list</Locator>
    		<Destination>params_list</Destination>
    		<DataType>string</DataType>
  		</Field>
    </Fields>
  </Response>
</ApiInteraction>

Use the next Data Connector applet (Extract specific virtual agent data) to get values from required parameters in params_list.

For information about using a Data Connector applet, see Retrieving data from and sending data to a Web Service.

...