IA Conversacional

Talk to your assistant: B2C scenario

This page describes the steps to get started using the Conversational AI API in a B2C scenario:

Step 1: Register your first user

Call the register method:

curl -X POST "https://api.sherpa.ai/v2/auth/register" \
-H  "accept: application/json" \
-H  "Accept-Language: es-ES" \
-H  "Time-Zone: Europe/Madrid" \
-H  "content-type: application/json" \
-d "{
    \"apiKey\": \"XXXX-SHERPA-DELIVERED-PUBLIC-APIKEY-XXXX\",
    \"email\": \"demo@sherpa.ai\",
    \"password\": \"chooseYourStrongPassword\",
    \"name\": \"demo\"    
}"

If it is OK, the response code will be 200 and the body will look like this:

{
    "token": "XXXX-SHERPA-TOKEN-XXXX",
    "type": "basic",
    "expires": 1858915823282,
    "username": "demo"
}

Step 2: Log in that user to get a token

Login the registered user:

curl -X POST "https://api.sherpa.ai/v2/auth/login" \
-H  "accept: application/json" \
-H  "Accept-Language: es-ES" \
-H  "Time-Zone: Europe/Madrid" \
-H  "content-type: application/json" \
-d "{  
    \"apiKey\": \"XXXX-SHERPA-DELIVERED-PUBLIC-APIKEY-XXXX\",
    \"email\": \"demo@sherpa.ai\",
    \"password\": \"chooseYourStrongPassword\",
    \"lat\": 43.3017218,
    \"lon\": -2.9735617
}"

If it is OK, the response code will be 200 and the body will look like this:

{
    "token": "XXXX-SHERPA-TOKEN-XXXX",
    "type": "basic",
    "expires": :1858915823282,
    "username": "demo"
}

This step can be omitted, because the register method already returned an authentication token.

Step 3: Talk to your assistant

Call the conversational service:

curl -X POST "https://api.sherpa.ai/v2/query/text" \
-H  "Authorization: Basic XXXX-SHERPA-TOKEN-XXXX" \
-H "Sherpa-Request-Info:{\"lat\":43.3017218,\"lon\":-2.9735617}" \
-H  "Accept-Language: en-US" \
-H  "Time-Zone: Europe/Madrid" \
-H  "accept: application/json" \
-H  "content-type: application/json" \
-d "{\"q\":\"Play a song by U2\"}"

If it is OK, the response code will be 200 and the body will look like this:

{
  "nextActions": [{
    "action": "PLAY_MUSIC",
    "data": {
      "url": "http://cdn-preview-b.deezer.com/stream/c-b326f0ee611077f4986866b1bdad697b-6.mp3"
    }
  }],
  "context": {
    "id": "ffb6eede-8d59-4c15-a380-c4bebf92dfa8",
    "ref": 406370837,
  },
  "responses": {
    "audio": "https://api.sherpalive.com//v2/query/audio/272806",
    "html": "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"es\" xml:lang=\"es\">... </html>",
    "query": "Play a song by U2",
    "speech": "Playing \"With Or Without You\" by \"U2\"",
    "ssml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><speak xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" version=\"1.0\" xml:lang=\"en\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis11/synthesis.xsd\"><voice gender=\"male\">Playing \"With Or Without You\" by \"U2\" </voice></speak>",
    "text": "Playing \"With Or Without You\" by \"U2\""
  }
}

You will get the action "PLAY_MUSIC" in the nextActions field and the URL with the song to play.

Play a song

For specific API information, demos, or requests, please contact us at info@sherpa.ai.