Custom Made Skill

I am building a Custom Skill of my own. The File Structure format is as per GitHub - MycroftAI/skill-stock: Mycroft AI official Stock Skill - providing current prices of stocks
However every time my skill responds with I do not understand. Any help is much appreciated!
The skill is supposed to return the Username. Find the relevant details (File names & their contents) below;
File Structure
image

UsernameKeyword.voc

user details
username

login.dialog

Your Username is {{username}}

not.found.dialog

Sorry your Username could not be found
My source did not reply to me

test/intent/login1.json
{
“utterance”: “Give me my Username”,
“intent_type”: “login_intent”,
“intent”: {
“UsernameKeyword”: “username”
}
}

test/intent/login2.json

{
“utterance”: “Give me my Username”,
“intent_type”: “login_intent”,
“intent”: {
“UsernameKeyword”: “user details”
}
}

init.py

import requests

from os.path import dirname

from adapt.intent import IntentBuilder
from mycroft.skills.core import MycroftSkill

class LoginSkill ( MycroftSkill ):
@intent_handler ( IntentBuilder ( “” )
.require ( “UsernameKeyword” ) )
def login_intent ( self , message ):
uname = message.data.get ( “UsernameKeyword” )
try:
response = self.find_and_query (uname)
self.speak_dialog ( “login” , data=response )
except Exception as e:
self.log.exception ( e )
self.speak_dialog ( “not.found”)

def find_and_query(uname):
    url = "URL_HERE"
    headers = {'Content-Type': 'application/json'}
    data = {'KEY1': 'VALUE1' , 'KEY2': 'VALUE2' , 'KEY3': VALUE3 , 'KEY4': VALUE4 ,
            'KEY5': 'VALUE5'}
    response = requests.post ( url , data , headers )
    finalresponse = response.json ( )
    username = finalresponse[ 'data' ][ 0 ][ 'dsm_name' ]
    return username

def stop ( self ):
        pass

def create_skill ( ):
    return LoginSkill ( )

Can you please also provide your mycroft-skills.log for debugging?
Thank you!

Hi, I have changed the structure a bit. It is now LoginSkill/vocab/en-us/UsernameKeyword.voc & similarly LoginSkill/dialog/en-us/login.dialog & LoginSkill/dialog/en-us/not.found.dialog

HI, the mycroft-skills.log https://drive.google.com/file/d/1TR1EtA8XgaEZ1f8yd5dzVqUg1AnVTgOY/view?usp=sharing

Hi @monikr_on_east thanks for this. I understand now you’re trying to build this Skill to integrate with an Enterprise API. You may want to use this Python library which makes working with Requests easier;

http://docs.python-requests.org/en/master/

I believe my colleague Ake @forslund has been providing assistance with Adapt Intents in Chat.

Regards,
Kathy

1 Like

@KathyReid Thanks for all the help. I was able to create the Skill successfully.

2 Likes

Fantastic! thanks for letting us know you got there in the end!