is it possible to make calls in qpython - qpython

im making an alexa like artificial intelligence/virtual assistant and have already added the ability to send texts, but cant figure out how to call. i found a post on how to make a notification when you get one, but not the ability to actally send them. is this even possible in qpython? thanks
example code:
response = input("enter command: ")
if response[1] == "call":
*call function* (response[2])
outcome:
enter command: call 123456789
calling 123456789

You can make a call with this code.
Insert phone number with country code as input of response
from androidhelper import Android
droid = Android()
response=input ("Enter phone number here:")
droid.phoneCallNumber (response)

Related

How can I properly upload too long messages as a file?

I was doing some research on Discord's capabilities today, and then I noticed that the "upload as file" option is given when a message is more than 2000 characters long.
The number plays a role here, but my statement can also be wrong, the fact is that some things are posted only as a link and or then not sent at all if I raise >2000.
Here now the problem:
I am requesting data from Genius for a lyrics command. I already have some kind of override built in for when len(data["lyrics"]) is greater than 2000 "characters", that should be Discord's limit after all, otherwise the bot wouldn't be able to process the embed I am trying to send.
How can I manage that lyrics >2000 are sent as a file?
Relevant code:
if len(data["lyrics"]) > 2000:
return await ctx.send(f"<{data['links']['genius']}>"))
This is the normal request, it works too, but it just throws out the link.
I then tried to send this via discord.File with the corresponding piece of code above, does not work. (Something like file=discord.File(data) was tried too!)
Something like ctx.file.send does not work in this case either
The following posts were viewed:
Uploading a file in a embed discord.py (not a image)
Discord.py - Sending a text file on DM
Discord.py Bot sending file to Discord Channel
Python discord.py ways to split output to bypass 2000 character limit
What I want my bot to do if data["lyrics"] > 2000:
You can save the text into a io.StringIO buffer and pass that into the discord.File constructor:
from io import StringIO
text = data["lyrics"]
if len(text) > 2000:
buffer = StringIO(text)
f = discord.File(buffer, filename="lyrics.txt")
await ctx.send(file=f)

Avoid rate limit for changing voice channel name discord js 13

I'm trying to create a slash command using discord.js v13 to change the names of voice channels. I am using this code to do this :
module.exports = {
data: new SlashCommandBuilder()
.setName('name')
.setDescription('Set name for your voice channel')
.addStringOption(option => option.setName('name').setDescription('Enter your name').setRequired(true)),
async execute(interaction) {
const name = interaction.options.getString('name');
if (!interaction.member.voice.channel) await interaction.reply('Error not in a voice channel!');
else {
await interaction.member.voice.channel.setName(name);
await interaction.reply('Done!');
}
},
};
This code is fine and makes the job done. But as you know I can change the voice channel's name only 2 times per 10 minutes because of the limit rate. So if a user tries to change the voice channel's name for the third time, I won't get any error on the console, and discord js will queue this request for later and will do it after 10 minutes. But the user gets this error on discord: This interaction failed.
I want to check if there was a rate limit for my request, and if is, don't send the request and just reply to the user. Is this possible?
There is no inherent functionality that is able to handle the situation in the way you want it to, but the problem is soluble using regular old JavaScript. For example, you could use an integer to indicate how many times the command has been used and use setTimeout() to decrement it 10 minutes after the command was called. That way you can check if the int is equal to 2 in which case you skip the .setName().
There are undoubtedly other ways to implement the same or similar behavior, but, to answer your question, unfortunately the discordjs/voice library does not provide any simple way to do it.

Deploy Watson AI (with option response function) in Node-RED

I'm using watson assistant were i have created a skill and in that i have used "option response". so i am deploying it in node-RED.
The problem is that in UI when watson interact with user upto when its not came up with "option response" but when watson has to response with option functionality then it's not showing any option!
as you can see here watson asked for email address and then next watson reply has to be in "option response" but its not showing.....
in function 1 node code is :-
msg.payload = msg.payload.text;
return msg;
in function 2 node code is :-
msg.payload = msg.payload.output.text[0];
return msg;
in form node :-
I tried to explain my problem as clear as I can. please! please! help me out with that.
if I have used less nodes or whatever it is please let me know.
I want to show what output watson has to show :
when I tried typing this code in function node 2 :
msg.payload =payload
then in debug node at that point where watson has to option response is like that :
Forgive me if I misunderstand you, but I believe you are trying to output into your bot response the options that Watson Assistant responds with. If this is the case you need to look at the JSON payload that is returned from Watson, as displayed in the debug node. Your function 2 is only returning the text response from assistant. The option responses are within a different part of the json payload, i.e.
msg.payload = msg.payload.output.generic[0].options[0].label
timd’s answer is actually correct. If you send only the text to the bot node, it will only display the test.
You need to check what format the bot node you are using expects payload to be in, and whether it can cope with options, and how it expects options to look like.
In your function node you will need to transform the output from the Assistant node into the expected input for the bot node.
Without knowing what bot node you are using and the input format it expects it is very difficult to go into more specifics, other than you are sending the wrong data.

Errors with multi turn dialog in alexa skills

I have created a skill with name "BuyDog" and its invocation name is "dog app"
So that should mean, I can use the intents defined inside only after the invocation name is heard. (is that correct?)
Then I have defined the Intents with slots as:
"what is {dog} price."
"Tell me the price of {dog}."
where the slot {dog} is of slot type "DogType". I have marked this slot as required to fulfill
Then I have added the endpoint to AWS lambda function where I have used the blueprint code of factskills project in node.js, and done few minor changes just to see the working.
const GET_DOG_PRICE_MESSAGE = "Here's your pricing: ";
const data = [
'You need to pay $2000.',
'You need to pay Rs2000.',
'You need to pay $5000.',
'You need to pay INR 3000.',
];
const handlers = {
//some handlers.......................
'DogIntent': function () {
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_DOG_PRICE_MESSAGE + randomFact;
}
//some handlers.......................
};
As per the about code I was expecting when
I say: "Alexa open dog app"
It should just be ready to listen to the intent "what is {dog} price." and the other one. Instead it says a random string from the node.js code's data[] array. I was expecting this response after the Intent was spoken as the slot was required for intent to complete.
And when
I say: "open the dog app and Tell me the price of XXXX."
It asks for "which breed" (that is my defined question) But it just works fine and show the pricing
Alexa says: "Here's your pricing: You need to pay $5000."
(or other value from the data array) for any XXXX (i.e. dog or not dog type).
Why is alexa not confirming the word is in slot set or not?
And when
I say: "open the dog bark".
I expected alexa to not understand the question but it gave me a fact about barking. WHY? How did that happen?
Does alexa have a default set of skills? like search google/amazon etc...
I am so confused. Please help me understand what is going on?
Without having your full code to see exactly what is happening and provide code answers, I hope just an explanation for your problems/questions will point you in the right direction.
1. Launching Skill
I say: "Alexa open dog app"
It should just be ready to listen to the intent...
You are expecting Alexa to just listen, but actually, Alexa opens your skill and is expecting you to have a generic welcome response at this point. Alexa will send a Launch Request to your Lambda. This is different from an IntentRequest and so you can determine this by checking request.type. Usually found with:
this.event.request.type === 'LaunchRequest'
I suggest you add some logging to your Lambda, and use CloudWatch to see the incoming request from Alexa:
console.log("ALEXA REQUEST= " + event)
2. Slot Value Recognition
I say: "open the dog app and Tell me the price of XXXX."
Why is alexa not confirming the word is in slot set or not?
Alexa does not limit a slot to the slot values set in the slotType. The values you give the slotType are used as a guide, but other values are also accepted.
It is up to you, in your Lambda Function, to validate those slot values to make sure they are set to a value you accept. There are many ways to do this, so just start by detecting what the slot has been filled with. Usually found with:
this.event.request.intent.slots.{slotName}.value;
If you choose to set up synonyms in the slotType, then Alexa will also provide her recommended slot value resolutions. For example you could inlcude "Rotty" as a synonym for "Rottweiler", and Alexa will fill the slot with "Rotty" but also suggest you to resolve that to "Rottweiler".
var resolutionsArray = this.event.request.intent.slots.{slotName}.resolutions.resolutionsPerAuthority;
Again, use console.log and CloudWatch to view the slot values that Alexa accepts and fills.
3. Purposefully Fail to Launch Skill
I say: "open the dog bark".
I expected alexa to not understand the question but it gave me a fact about barking.
You must be doing this outside of your Skill, where Alexa will take any inputs and try to recognize an enabled skill, or handle with her best guess of default abilities.
Alexa does have default built-in abilities (not skills really) to answer general questions, and just be fun and friendly. You can see what she can do on her own here: Alexa - Things To Try
So my guess is, Alexa figured you were asking something about dog barks, and so provided an answer. You can try to ask her "What is a dog bark" and see if she responds with the exact same as "open the dog bark", just to confirm these suspicions.
To really understand developing an Alexa skill you should spend the time to get very familiar with this documentation:
Alexa Request and Response JSON Formats
You didn't post a lot of your code so it's hard to tell exactly what you meant but usually to handle incomplete events you can have an incomplete even handler like this:
const IncompleteDogsIntentHandler = {
// Occurs when the required slots are not filled
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'DogIntent'
&& handlerInput.requestEnvelope.request.dialogState !== 'COMPLETED'
},
async handle(handlerInput) {
return handlerInput.responseBuilder
.addDelegateDirective(handlerInput.requestEnvelope.request.intent)
.getResponse();
}
you add this handler right above your actual handler usually in the index.js file of your lambda
This might not fix all your issues, but it will help you handle the event when a user doesn't mention a dog.

How to Develop alexa to speak latest response again

In Details:
Example:
user:- asks About Cricket News.
Alexa:- Reads about the new.
If users says come again or replay
user: Come again.
Alexa: Must read it again what it spoke earlier.
How to handle this situation using webhooks.
Thanks in advance.
You can make use of sessionAttributes to keep track of the last response that Alexa spoke. Whenever you return a response just store the speech and re-prompt in sessionAttributes and whenever a ComeAgainIntent is triggered, take the value from the sessionAttributes and respond accordingly.
Ex:
...
"sessionAttributes": {
"lastResponse": {
"speech": "This was my last speech",
"reprompt": "This was my lst reprompt"
}
}
...
Every time before building the response store the response as lastSpeech in session attributes and write a comeAgainIntent or use amazon.REPEAT intent to repeat the response by getting lastSpeech from session attributes.

Resources