Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: Tsim Amazon Tus Tsim Tus Kheej
- Kauj Ruam 2: Tsim Tus Kheej Tshiab
- Kauj ruam 3: Txais tos tus neeg siv
- Kauj Ruam 4: Xeem Kev Txais Tos
- Kauj Ruam 5: Ntxiv Kev Xav
- Kauj Ruam 6: Ntxiv Cov Lus Zoo
- Kauj Ruam 7: Ntxiv Cov Neeg Ua Haujlwm Xav Tau
- Kauj Ruam 8: Sau npe Cov Neeg Ua Haujlwm Xav Tau
- Kauj Ruam 9: Xeem Txuj Ci
- Kauj Ruam 10: Teeb Ua Ntej Ua Ntej Ua Ntej thiab Xa rau Tshawb Xyuas
Video: Yuav Ua Li Cas Tsim Alexa Skill: 10 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Dab tsi yog alexa txuj ci?
Kev txawj ntse Alexa zoo li cov apps. Koj tuaj yeem qhib thiab kaw qhov txuj ci, siv Alexa app lossis lub vev xaib, zoo ib yam uas koj nruab thiab tshem tawm cov apps ntawm koj lub xov tooj ntse lossis ntsiav tshuaj. Cov txuj ci yog lub peev xwm hais lus Alexa. Koj tuaj yeem ntxiv Alexa cov txuj ci rau koj li Echo kom coj cov khoom lag luam thiab kev pabcuam rau lub neej. Koj tuaj yeem saib cov txuj ci uas muaj thiab ua haujlwm lossis ua rau lawv siv koj li Alexa app.
Phau ntawv qhia no qhia koj yuav ua li cas tsim kev txawj alexa.
Lub hom phiaj:
Lub hom phiaj yog, txhawm rau tsim txuj ci, uas qhia tus neeg siv cov lus german lom zem txhua lub sijhawm, tus neeg siv nug.
Demo:
Txhawm rau pom, yuav ua li cas cov txuj ci yuav tsum ua haujlwm tom qab, koj tuaj yeem sim nws ntawm no:
www.amazon.com/gp/product/B07ZH9GL9N?ref&r…
Khoom siv
- Kev paub hauv programming
- Pib hauv Node.js thiab Javascript
Kauj Ruam 1: Tsim Amazon Tus Tsim Tus Kheej
Muab koj tsis muaj Amazon Tus Tsim Kho Tus Kheej koj tuaj yeem sau npe ntawm no. Txwv tsis pub koj tuaj yeem kos npe rau ntawm no.
Kauj Ruam 2: Tsim Tus Kheej Tshiab
- Ua raws qhov txuas no:
- Nyem rau Tsim Kev Txawj Ntse ntawm sab xis. Ib nplooj ntawv tshiab qhib tom qab.
- Sau lub npe ntawm koj qhov txuj ci (hauv peb qhov xwm txheej: Cov Lus Zoo Tshaj Lij German) hauv Cov Npe Txawj Ntse.
- Teem cov lus hauv Hom Lus Xaiv-Box rau Askiv (Asmeskas)
- Peb tab tom yuav tsim kev cai tshwj xeeb, yog li peb xaiv Tus Qauv Tshwj Xeeb
- Ntawm Xaiv ib txoj hauv kev los tuav koj qhov kev txawj ntse backend cov peev txheej peb xaiv Alexa-Hosted (Node.js)
- Tom qab koj ua tiav nyem rau ntawm Tsim kev txawj
- Lub qhov rai tshiab qhib
Kauj ruam 3: Txais tos tus neeg siv
Thawj qhov uas tus neeg siv ua nrog koj qhov txuj ci nws qhib nws. Lub hom phiaj, uas qhib qhov txuj ci twb tau ua tiav hauv cov qauv coj ua thiab tsis tas yuav ntxiv ntxiv lawm.
-
Qhib qhov Code tab → Lub qhov rai chaws nrog cov ntawv index.js qhib
Txhua tus neeg tuav lub hom phiaj muaj ob txoj haujlwm
- canHandle ()
- tuav ()
CanHandle () muaj nuj nqi suav nrog qhov kev thov, tus tuav haujlwm teb rau.
Tus kov () muaj nuj nqi xa cov lus teb rau tus neeg siv.
Yog tias qhov txuj ci tau txais kev thov, canHandle () muaj nuj nqi ntawm txhua tus neeg tuav lub hom phiaj tau hu thiab tshawb xyuas, yog tias nws tuaj yeem xa cov lus teb rau qhov kev thov ntawd.
-
Hauv kev tuav () ua haujlwm ntawm LaunchRequestHandler rho tawm tag nrho cov cai thiab muab cov hauv qab no tom qab:
const speakOutput = 'Zoo siab txais tos rau cov lus German lom zem. Tshawb nrhiav cov lus txaus luag uas lus German tau muab thiab lawv txhais li cas. Koj puas xav hnov lo lus luag ntxhi? ';
const repromptText = 'Koj puas xav hnov cov lus German txaus luag?'; xa rov qab handlerInput.responseBuilder.speak (speakOutput).reprompt (repromptText).getResponse ();
- Nyem rau Txuag thiab Siv.
Qhov kev pab cuam lub hom phiaj xav tau hloov pauv kom haum nrog cov txuj ci. Rho tawm cov cai ntawm tus tuav () ua haujlwm thiab ntxig qhov no:
const speakOutput = 'Tshawb nrhiav cov lus txaus luag uas lus German tau muab thiab lawv txhais li cas. Koj puas xav hnov lo lus luag ntxhi? ';
const repromptText = 'Koj puas xav hnov cov lus German txaus luag?'; xa rov qab handlerInput.responseBuilder.speak (speakOutput).reprompt (repromptText).getResponse ();
Tom qab ua tiav qhov no nyem Txuag thiab Siv.
Kauj Ruam 4: Xeem Kev Txais Tos
Txhua lub sijhawm koj muaj kev ua haujlwm tau zoo dua rau koj qhov kev txawj, sim yog tias nws ua haujlwm tiag tiag, txhawm rau tshawb pom thaum muaj qhov ua yuam kev, qhov twg tuaj yeem ua yuam kev.
- Nyem rau ntawm Test tab → Lub qhov rai tshiab qhib.
- Qhib qhov chaw sim, los ntawm kev xaiv Kev Txhim Kho hauv lub thawv xaiv.
- Sau lossis hais lus: "oppen lus txaus luag German" skill Cov txuj ci tam sim no yuav tsum teb nrog kev tos txais.
Kauj Ruam 5: Ntxiv Kev Xav
Tam sim no peb yuav ntxiv txoj hauv kev li cas tus neeg siv tuaj yeem cuam tshuam nrog koj cov txuj ci. Lub hom phiaj ua rau nws muaj peev xwm ua kom raug tom qab cov lus tshwj xeeb thiab ua rau tus neeg ua haujlwm tsis txaus siab tom qab.
- Nyem rau ntawm Build tab → Lub qhov rais qhib qhib.
- Qhov bar qhia ntawm sab xis qhia tag nrho cov kev xav tau qhib. Ua ntej tshaj plaws, rho tawm HelloWorldIntent.
- Tom qab ntawv nyem rau ntawm Add Button nyob ib sab ntawm lub siab xav tab hauv qhov bar navigation.
Ua ntej tshaj plaws, peb ntxiv qee qhov ua hauv kev xav los ntawm Alexa lub tsev qiv ntawv built-in
- Nyem rau ntawm Siv lub hom phiaj uas twb muaj lawm los ntawm Alexa lub tsev qiv ntawv built-in
- Nrhiav YesIntent thiab NoIntent thiab nyem ntxiv los ntawm ob qho tib si.
Tam sim no peb ntxiv peb tus kheej lub hom phiaj kev xav.
- Nyem rau ntawm Tsim kev mob siab rau
- Muab lub npe TellAFunnyWordIntent rau lub hom phiaj
- Nyem rau ntawm Tsim kev mob siab rau
Tam sim no peb yuav ntxiv qee cov lus piv txwv rau peb lub hom phiaj. Cov kab lus piv txwv yog kab lus uas tus neeg siv tuaj yeem hais tau. Tsuas yog sau cov kab lus piv txwv:
- qhia kuv ib lo lus
- qhia kuv ib lo lus German lom zem
- ib lus
- lus funny
- los qhia kuv ib lo lus
Tau kawg muaj ntau nqe lus ntau ntxiv uas tus neeg siv tuaj yeem hais. Koj tuaj yeem txuas ntxiv lub hom phiaj yog tias koj xav tau, tab sis peb tau tsom mus rau kev ua haujlwm tau zoo tam sim no.
Tom qab ntxiv cov kab lus, nyem rau Txuag Qauv thiab tom qab ntawd ntawm Tsim Qauv. Tom qab tsim tiav, rov qab mus rau Code tab.
Kauj Ruam 6: Ntxiv Cov Lus Zoo
Txhawm rau ua peb cov txuj ci qhia cov lus txaus luag, nws xav tau qee cov lus lom zem ua ntej.
Txog qhov ntawd, tsim cov ntawv tshiab hu ua words.json hauv daim nplaub tshev lambda.
Ntxig cov lus ntawd rau hauv cov lus.json file:
[{"lo lus": "Lebensabschnittpartner", "piav qhia": "Lo lus no tau piav ntau tshaj li lwm qhov kev xaiv rau tus khub lossis tus hlub, tab sis nrog kev hloov pauv ntau dua." }, {"lo lus": "Unabhängigkeitserklärungen", "piav qhia": "Lo lus no piav qhia txog kev tshaj tawm ntawm kev ywj pheej." }, {"lo lus": "Freundschaftsbezeugung", "piav qhia": "Nws yog kev qhia ua phooj ywg." }, {"lo lus": "Rechtsschutzversicherungsgesellschaften", "piav qhia": "Phau Ntawv Guinness Phau Ntawv Teev Npe Ntiaj Teb lees paub lo lus nyuaj no yog lo lus German ntev tshaj plaws hauv kev siv niaj hnub. Nws txhais tau tias cov tuam txhab pov hwm muab kev tiv thaiv raug cai." }, {"lo lus": "Kaftfahrzeug-Haftpflichtversicherung", "piav qhia": "Nws hais txog kev tuav pov hwm lub tsheb loj." }, {"lo lus": "Donaudampfschiffahrtsgesellschaftskapitän", "piav qhia": "Lo lus no txuas ntxiv lub ntsiab lus ntawm kev thauj mus los, thiab yog plaub lo lus sib dhos ua ke kom hais tau Danube lub nkoj ua lag luam tus thawj coj." }]
Tau kawg koj tuaj yeem ntxiv cov lus yog tias koj paub qee yam. Tab sis rau kev sim nws yuav tsum tau ua haujlwm.
Nyem rau Txuag thiab Deploy dua.
Kauj Ruam 7: Ntxiv Cov Neeg Ua Haujlwm Xav Tau
Cov kev xav yav dhau los tsim tam sim no xav tau tus tswj hwm, uas yog ua los ntawm lub hom phiaj. NoIntentHandler kaw qhov txuj ci. YesIntentHandler thiab TellAFunnyWordIntentHandler teb nrog cov lus lom zem thiab nws cov lus piav qhia.
Rho tawm tag nrho HelloWorldIntentHandler los ntawm cov ntawv index.js thiab ntxiv peb qhov tshiab los hloov:
const TellAFunnyWordIntentHandler = {
canHandle (handlerInput) {xa Alexa.getRequestType (handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName (handlerInput.requestEnvelope) === 'TellAFunnyWordIntent'; }, handle (handlerInput) {const words = JSON.parse (fs.readFileSync ('./ words.json')); const lo lus = lo lus [Math.floor (Math.random () * words.length)]; const hais lusOutput = word.word + '. ' + lo lus.explanation; xa rov qab handlerInput.responseBuilder.speak (speakOutput).getResponse (); }}; const YesIntentHandler = {canHandle (handlerInput) {return Alexa.getRequestType (handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName (handlerInput.requestEnvelope) === 'AMAZON. YesIntent'; }, handle (handlerInput) {const words = JSON.parse (fs.readFileSync ('./ words.json')); const lo lus = lo lus [Math.floor (Math.random () * words.length)]; const hais lusOutput = word.word + '. ' + lo lus.explanation; xa rov qab handlerInput.responseBuilder.speak (speakOutput).getResponse (); }}; const NoIntentHandler = {canHandle (handlerInput) {return Alexa.getRequestType (handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName (handlerInput.requestEnvelope) === 'AMAZON. NoIntent'; }, tuav (handlerInput) {const speakOutput = 'Okay, tej zaum lwm lub sijhawm.'; xa rov qab handlerInput.responseBuilder.speak (speakOutput).getResponse (); }};
Kauj Ruam 8: Sau npe Cov Neeg Ua Haujlwm Xav Tau
Tam sim no peb yuav tsum sau npe tus tswv lub hom phiaj tshiab. Txog qhov ntawd, nqes mus rau qhov kawg ntawm cov ntawv index.js.
Hloov qhov no:
xa tawm.handler = Alexa. SkillBuilders.custom ()
.addRequestHandlers (LaunchRequestHandler, HelloWorldIntentHandler, HelpIntentHandler, ยกเลิก
nrog ntawd:
xa tawm.handler = Alexa. SkillBuilders.custom ()
.addRequestHandlers (LaunchRequestHandler, TellAFunnyWordIntentHandler, YesIntentHandler, NoIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler, IntentReflectorHandler, // ua kom yuam kev (tsis txhob yuam kev)
Tom qab ntawv nyem rau Save thiab Deploy dua. Tom qab qhov kev xa tawm tau ua tiav qhov kev sim dua.
Kauj Ruam 9: Xeem Txuj Ci
- Nyem rau ntawm Test tab → Lub qhov rai tshiab qhib.
- Sau lossis hais lus: "oppen lus txaus luag German" skill Cov txuj ci tam sim no yuav tsum teb nrog kev tos txais.
- Sau lossis hais lus: "qhia kuv cov lus german lom zem" → Cov txuj ci tam sim no yuav tsum qhia ib qho ntawm cov lus.
Yog tias txhua yam ua haujlwm, koj tuaj yeem xa koj cov txuj ci.
Kauj Ruam 10: Teeb Ua Ntej Ua Ntej Ua Ntej thiab Xa rau Tshawb Xyuas
Sau tag nrho cov ntawv xav tau nrog koj tus kheej piav qhia txog kev txawj.
Ntawm Piv Cov Kab lus sau:
- Alexa, qhib Cov Lus German Funny.
- Alexa, nug Cov Lus German Zoo los qhia kuv cov lus lom zem.
Tom qab koj tau ua tiav txhua qhov chaw xav tau thiab tom qab koj tau rub tawm cov cim, nyem rau Txuag thiab txuas ntxiv.
Xaiv cov lus teb raug ntawm Tsis pub twg paub & Sib piv thiab ntawm Kev Muaj.
Thov ua tibzoo saib daim ntawv teev npe xa ua ntej xa
Tam sim no koj yuav tsum tau ua qee qhov kev xeem. Qhov no tuaj yeem siv sijhawm me ntsis.
Tom qab ntawd koj tuaj yeem xa koj cov txuj ci los tshuaj xyuas. Nws yuav siv sijhawm 1 lossis 2 hnub kom txog thaum koj tau txais cov lus tawm tswv yim rau koj qhov txuj ci. Yog tias koj ua txhua yam raug, koj qhov txuj ci yuav raug tshaj tawm tom qab tshuaj xyuas.
Yog tias koj xav sim qhov txuj ci dhau los, tab sis nws tseem nyob hauv ntawv pov thawj, koj tuaj yeem siv qhov txuj ci no ib txwm:
www.amazon.com/gp/product/B07ZH9GL9N?ref&ref=cm_sw_em_r_as_dp_uCOJljYBKfNx9
Pom zoo:
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM MUAJ KEV LAG LUAM CIRCUIT Siv D882 Tus Neeg Soj Ntsuam: 3 Kauj Ruam
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM TAU LWM YAM CIRCUIT Siv D882 Tus Kws Tshaj Lij: HELLO phooj ywg, Zoo siab txais tos rau kuv CHANNEL, Hnub no kuv yuav qhia koj li cas kom ua tau CIRCUIT ntawm kev siv hluav taws xob tsis siv neeg lub teeb pom kev siv D882
Yuav Ua Li Cas Tsim Linux Boot Drive (thiab Yuav Siv Li Cas): 10 Cov Kauj Ruam
Yuav Ua Li Cas Tsim Linux Boot Drive (thiab Yuav Siv Li Cas): Nov yog cov lus qhia yooj yim yuav pib li cas nrog Linux, tshwj xeeb yog Ubuntu
YUAV UA LI CAS YUAV UA LI CAS YUAV TSUM ROBOT COOB SCARECROW: 16 Cov Kauj Ruam (nrog Duab)
YUAV UA LI CAS YUAV TSUM NYOB ROBOT COW SCARECROW: Kuv nyuam qhuav tsim Moo-Bot, tus neeg hlau nyuj scarecrow dhia hla lub hli, rau kev sib tw hauv zej zog scarecrow.Kuv kev tshoov siab yog los ntawm kuv tus tub hu nkauj "hey diddle diddle, miv thiab fiddle. .. " Txoj haujlwm zoo heev los ua haujlwm nrog kuv
Yuav Tsim Tus Qauv Li Cas thiab Tsim PCB Siv Autodesk EAGLE: 9 Kauj Ruam
Yuav Ua Li Cas Tsim Kev Tsim Vaj Tsev thiab Tsim PCB Siv Autodesk EAGLE: Muaj ntau yam CAD (Khoos Phis Tawj Pab Tsim) software tawm uas tuaj yeem pab koj tsim thiab ua PCBs (Luam Circuit Board), qhov teeb meem tsuas yog feem ntau ntawm lawv tsis t piav qhia yuav siv lawv li cas thiab lawv tuaj yeem ua dab tsi. Kuv tau siv ntau t
Yuav Ua Li Cas: Tsim Tus Tsim Tus Zauv Tus lej Random Nrog Python: 8 Kauj Ruam
Yuav Ua Li Cas: Tsim Tus Tsim Tus Qauv Tsim Tus Kheej Nrog Python: Hauv qhov kev qhia no, koj yuav kawm paub yuav tsim lub tshuab hluav taws xob tus lej zais siv tus nab npawb li cas hauv ob peb kauj ruam yooj yim