Alexa Device Integration into Mobile IoT App
Alexa Smart Home — not one API, but three different paths depending on task. Managing smart home through Alexa Skills Kit (ASK) with Smart Home Skill — for third-party devices wanting voice command support. Alexa Mobile Accessory Kit (AMAK) — for Bluetooth accessories connected to Echo devices. Alexa Voice Service (AVS) Integration — embedding voice assistant directly in mobile app. Usually mobile development needs either Smart Home Skill or AVS.
Smart Home Skill: Device Control via Alexa
Working scheme: user says "Alexa, turn on light," Alexa Smart Home sends directive to developer Lambda function, Lambda controls real device via backend or directly. Mobile app in this scheme — configuration and authorization point, not control.
Account Linking — key step. User authorizes Alexa via OAuth 2.0 on developer server. Alexa then gets access token and passes it with each directive:
{
"directive": {
"header": {
"namespace": "Alexa.PowerController",
"name": "TurnOn"
},
"endpoint": {
"endpointId": "device-001",
"scope": {
"type": "BearerToken",
"token": "user-access-token"
}
}
}
}
Lambda processes directive and responds. For successful Alexa Smart Home Certification Response must arrive within 8 seconds — hard deadline.
Mobile app opens WebView for Account Linking or uses Custom URL Scheme for OAuth redirect:
// iOS: handle OAuth callback
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url,
url.scheme == "myapp",
url.host == "alexa-auth" else { return }
let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
let code = components?.queryItems?.first(where: { $0.name == "code" })?.value
// Exchange code for token via backend
}
AVS Integration: Alexa in Mobile App
Alexa Voice Service lets embed voice assistant in app. SDK available for Android via com.amazon.alexa:avs-device-sdk-android (deprecated) or via Alexa Auto SDK for automotive apps. Official path for mobile — AVS API directly via HTTP/2:
POST https://avs-alexa-eu.amazon.com/v20160207/events
Content-Type: multipart/form-data; boundary=boundary
Authorization: Bearer {access_token}
--boundary
Content-Disposition: form-data; name="metadata"
Content-Type: application/json
{
"event": {
"header": {
"namespace": "SpeechRecognizer",
"name": "Recognize",
"messageId": "uuid"
},
"payload": {
"profile": "CLOSE_TALK",
"format": "AUDIO_L16_RATE_16000_CHANNELS_1"
}
}
}
--boundary
Content-Disposition: form-data; name="audio"
Content-Type: application/octet-stream
[PCM audio data 16kHz, 16-bit mono]
--boundary--
AVS responds with multipart response containing directives and TTS audio. Audio stream must be captured via AVAudioEngine on iOS or AudioRecord on Android with 320-byte buffer (20ms) for minimal latency.
In practice pure AVS API integration takes longer than appears: dialog state management (Dialog Request ID), downstream directive handling via long-lived HTTP/2 (Downchannel), wake word support — separate task each.
Alexa for Android: APL and Visual Responses
Alexa Presentation Language (APL) lets display visual cards on screened Echo devices and apps with APL renderer. Android SDK for APL:
implementation("com.amazon.alexa:apl-android-sdk:2024.1")
APL document — JSON describing interface. Renderer displays it without writing native code per platform.
Most common AVS integration problem — microphone management in background. Android 10+ requires FOREGROUND_SERVICE with microphone type for audio capture when app not foreground. Without <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE"/> app crashes with SecurityException on service start.
Smart Home Skill Publication
Certify Alexa Smart Home Skill via Alexa Developer Console. Main requirements: Account Linking via HTTPS, correct Response for all declared Capability Interfaces, handle Alexa.Discovery request — return user's device list.
Typical certification rejection reason — incorrect ChangeReport on state change not from Alexa command. If user turned on light with physical switch, Smart Home Skill should send ChangeReport via Alexa Event Gateway.
Timeline: Account Linking and basic Smart Home Skill — 2-3 weeks. Full implementation with AVS, APL and multiple Capability Interfaces — 5-7 weeks. Cost calculated after analyzing devices and scenarios.







