Talk to your assistant: B2B scenario
This page describes the steps to get started using the Conversational AI API in a B2B scenario:
Step 1: Anonymous register
Anonymous register/login method request example:
curl -X POST "https://api.sherpa.ai/v2/auth/user" \
-H "accept: application/json" \
-H "Accept-Language: es-ES" \
-H "Time-Zone: Europe/Madrid" \
-H "X-Sherpa-apikey: XXXX-SHERPA-DELIVERED-PUBLIC-APIKEY-XXXX" \
-H "X-Sherpa-timestamp: 1548084514112" \
-H "X-Sherpa-nonce: XXXX-SHERPA-RAMDOM-UUID-XXXX" \
-H "X-Sherpa-hmac: xxxxyyyyyyy***signature******" \
-H "content-type: application/json" \
-d "{
\"externalId\": \"demo@sherpa.ai\",
\"name\": \"demo\",
}"
Response example:
{
"token": "XXXX-SHERPA-TOKEN-XXXX",
"type": "basic",
"expires": :1858915823282,
"username": "demo"
}
HTTP code 201 should be obtained in the first call. If a second call is made, HTTP code 200 will be returned.
Step 2: Talk to your assistant
Call the conversational service using the obtained security token:
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\"}"
Response example:
{
"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.
For specific API information, demos, or requests, please contact us at info@sherpa.ai.