I'm trying to setup a Microsoft Bot Framework bot using Python, a Direct Line Channel for Speech to Text and some Luis resources for NLP.
I've managed to get the bot working with Teams (and WebChat) but I can't figure how to correctly use the Direct Line Speech Channel. The bot is a variation of the Multi-turn prompt bot that I iterated upon (mostly by altering the dialog part, I didn't touch the rest of the bot).
I've tried following this tutorial, which led me to configure my Channel Registration and App service correctly. Following that, I've done some test using the clients provided here and got the following error on each and everyone of them:
Connection was closed by the remote host. Error code: 1002. Error details: The server returned status code '503' when status code '101' was expected. SessionId: fc7a098e75e44379b18330e8385104a9
This led me to believe that my bot was misbehaving and refusing Direct Line Speech messages.
Rereading the earlier tutorial led me to this one which is where I am stuck. It asks to do a bunch of modifications on C# code so that the bot interpret and uses websockets correctly. However, my bot is written using the Python version of the SDK, and I can't find an equivalent tutorial for how to setup Direct Line Speech in a Python bot.
Could you advise me as to how I should go about it ? I'd prefer not to have to rewrite the whole thing in C#.
September 2020 edit: I've resorted to rewriting the whole thing in C#, it works now.
Related
Since this stack is new to me I'd figure it wouldnt hurt to ask the community for input.
I'm exploring a new type of project and have been brainstorming how/if it's possible to communicate between an apollo-graphql server (NodeJS) and a client Python program. I have a web development background and I intend to keep my app and server in Typescript/Node.
However ...
As a project and exercise, I would like to play around with connecting a watering system via the GPIO package in Python + RaspberryPi and then send the updates to my apollo-graphql server. I think conceptually, in a traditional RESTful api it would be straightforward ... However, with GraphQL things are a bit more nebulous to me. It would be nice to build out hardware connected services in various languages as appropriate and not be bottled into having everything in typescript/node and to that end Python is the most widely used language within the RaspberryPi community.
Has anyone done this before, or something similar, and have insights and experience to share?
edit: since posting I became more familiar with graphql and played around with it in Postman. It simply has an endpoint that I can post to it with queries (and I assume mutations and everything else) and it's captured by my NodeJS apollo-graphQL server. I ended up using this python package to query against my node API and it seems to work well.
Your server is node and your client is python. The server doesn't care at all whether your client is python or java or C#, it only wants to see GraphQL requests.
I suggest using a python-based GraphQL client package such as python-graphql-client
You're right that in the end everything looks like a POST. Using an actual client might make life a little bit easier for you though.
You can try calling your GraphQL service using a RESTful wrapper: https://graphql.org/blog/rest-api-graphql-wrapper/. There's a similar question asked before: link.
Secondly, instead of calling the server directly, you could also try using a message broker in the middle. In short: the raspi sends messages to a queue that is polled by your server. There are several solutions available like: Rabbitmq.
I've been hosting a discord bot on an online IDE but it happens to disconnect from the API after a while. The code on the IDE continues to run, but on discord, it is unable to respond to commands and essentially the entire bot is completely offline, while a running code is being executed. Even more suprising is a background task that I have assigned to run every minute continues to do it's job ( which is to edit a embed in a server with new information ). I've been going through the documentation and about the gateway kinda stuff but I'm utterly confused. It states that disconnections are regular but never teaches me how to actually connect again rather some snippets of JSON data. Documentation here : https://discord.com/developers/docs/topics/gateway#gateway-intents
I'm a bit new to this stuff but the documentation clearly doesn't talk anything about the way to connect to the gateway, and what to do during a op7 reconnect. How would I be able to incorperate this reconnection thing with my discord bot also?
I am using the PicklePersistence example provided in python telegram bot github.
https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/persistentconversationbot.py
Sometimes the bot doesn't /start. After troubleshooting, I discovered that the problem is caused by the pickle persistence file. To get /start to work, I had to delete persistence file. It seems the persistence file is corrupted.
What can be done to make the pickle persistence file more robust against corruption?
I am using python telegram bot 12.4.2 and python v3.7
I will answer my own question.
The reason /start cannot be reentered is due to the state machine of the bot. Because persistence was turned on, this state is always remembered even after the bot is shut down and restarted.
The solution to fix my problem was to set allow_reentry to True. Verified to work in my case.
https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.conversationhandler.html
I am trying to get an RPi3 robot to accept commands from both the Web and from a touchscreen/keyboard interface. I have a script that handles the keyboard and I am looking for that current script I have in Python to be expanded to accept real-time input from the web. As well as trying to figure out how to send the data to the script.
More detail is below but that is the basic question.
I created the robot using a raspberry pi and 3 arduinos controlling DC motors and servos to make the bot move. The program is written in Python and is run from the command line. when run it:
queries the active serial ports on the Raspberry
opens each available port
sends an integer to the receiving arduino
the arduino responds with an identifying integer so the RPI can name the port
then the script waits for user input like "Forward"
the command is translated and sent to the correct port
the robot moves
This all works perfect. Now I want to expand it. I want to keep this functionality intact and add in a web interface so I can control it from anywhere. I've tried a couple of different things with no success. I have installed apache and I am able to serve the pages with no problem, I can get the data on the page, but I can't figure out how to get the web page to send the data to the running arduino script. My issue stems from the fact that the bot control script needs to run independent of the web page. I want to still keep the same input now from the keyboard, but I also want it to accept the data from the web page. If I invoke the bot controller from the web page each time it will need to re-establish the port connections each time which takes up to 20 seconds...
I am thinking if I create a listening script I can have the website invoke the listener which will run only to receive the data from the web and pass it to the bot controller and back. But I am not sure how to do this or if this is even the best way.
I've looked at websockets, CGI/wsgi, Flask, writing a file, and JSON and I just can't seem to string it all together.
Thanks in advance and apologies if this is not in the right place or has been answered before. Also, I have not included any code as the only solid code is the bot controller. I am hoping someone with some real expertise can help me unravel this.
thanks in advance
KenV
I would say Flask is your best option. A simple example of how you could use it:
from my_robot_stuff import move_forward
#app.route('/move_forward')
def move_forward_flask():
move_forward()
return redirect('/')
Your html would then have a button that says move forward that directs to mysite.com/move_forward. flask would process it, run the code, then redirect back to the root.
I am a newbie to XMPP World. I have being struggling getting my head around it. I found a book called the Definitive Guide to XMPP. It uses the SleepXMPP library. There is a sample code I wanted to test, but didn't get through. I visited the SleekXMPP Getting Started guide, but still don't know how to get my head around it.
This is my problem. How do I run the code on this page getting started SleekXMPP
It says that:
You can run the code using:
python echobot.py -d -j echobot#example.com
which will prompt for the password and then begin echoing messages. To test, open
your regular IM client and start a chat with the echo bot. Messages you send to it should
be mirrored back to you. Be careful if you are using the same JID for the echo bot that
you also have logged in with another IM client. Messages could be routed to your IM client instead
of the bot.
I have not created any password anywhere in the guide. I have not created any JID also. ANd what do they mean by a "To test, open
your regular IM client". Regular Client?
I am confused, any help will be appreciated. Thank you.