Send message to IRC channel using SaltStack - salt-stack

I have a custom SaltStack event and want to send a message to our IRC when the event occurs. I know how to hook into this event. Question is: How to send a message to our IRC server using SaltStack?
There is an ircbot engine.
The documentation on engines say:
Salt Engines are long-running, external system processes that leverage Salt.
This sounds like the tool that I need.
But I did not find an example how to send a message to the ircbot from a Salt State. The examples only show how to send a message to the ircbot from an already logged in IRC user.

The ircbot engine is not currently setup to handle what you are asking for. It is a generic engine that only takes commands and returns results based on that command.
It is mostly used as an example engine for designing your own. So could be updated to a custom engine to do what you are asking about.

Related

Hot to get callback data from telegram bot message

I'm developing a Telegram Bot via PHP and I want users to answer bot question.
For Example:
Bot: What is your name?
User: (Reply)
But I don't know how to process user reply for specific question from bot.
If I receive user reply via webhook, it doesn't contain last bot message, and I don't know what question this reply is.
Webhook has parameter callback_query, but it works only for messages that contains inline keyboard.
Can you help please?
This process is called conversation. There are various ways to implement this.
The best and common way is to implement a Finite State Machine which will save the current state and accordingly, have a conversation with a user. Famous libraries like python-telegram-bot already implement it, which can give you a general idea on how to do this. Other ways can be storing last message in a database, etc; which is not recommended.

OpenStack Cluster Event Notification

So far, based on my understanding of OpenStack Python SDK, I am able to read the Hypervisor, Servers instances, however, I do not see an API to receive and handle the change notification/events for the operations that happens on the cluster e.g. A new VM is added, an existing VM is deleted etc.
There is a similar old post (circa 2016) and I am curious if there have been any changes in Notification handling?
Notifications to external systems from openstack
I see a documentation, which talks about emitting notifications over a message bus that indicate different events that occur within the service.
https://docs.openstack.org/ironic/latest/admin/notifications.html
I have the following questions:
Does Openstack Python SDK support notification APIs?
How do I receive/monitor notifications for VM related changes?
How do I receive/monitor notifications for compute/hypervisor related changes?
How do I receive/monitor notifications for Virtual Switch related changes?
I see other posts such as Notifications in openstack and they recommend to use Ceilometer project, which uses a Database. Is there more light-weight solution than using a completely different service like Ceilometer?
Thanks in advance for your help in this regard.
As far as I see and I know, Openstack SDK doesn't provide such a function.
Ceilometer will also not help you. It only collects data by polling and by notifications over RPC. You would still have to poll the data from ceilometer by yourself. Beside this, ceilometer alone has the problem, that it only grow and will blow up your database, that's why you should also use gnocchi, when you use ceilometer.
At the moment I see only the 3 possible solutions for you:
Write your own tool, which runs permanently in the background and collect the data in a regular interval over OpenstackSDK and REST-API requests.
Write something, which does the same like ceilometer by reciving notifications over oslo-messaging (RPC). See the oslo_messaging_notifications-section in the configs: https://docs.openstack.org/ocata/config-reference/compute/config-options.html#id35 (neutron has also such an option) and use messagingv2 as driver like ceilometer does. But be aware here, that not every event creates a notification. The list of the ceilometer meter-data should give a good overview of which event are creating a notification and what can only be collected by polling: https://docs.openstack.org/ceilometer/pike/admin/telemetry-measurements.html. The number of notification-events is really low, so its possible, that it doesn't provides all events you want.
Use in the oslo_messaging_notifications-section in the configs log as driver to write the notification in a log-file, and write a simple program to read the log-file and process or forward the read content. Here is the same problem like in number 2, that not every event creates a notification (log-entry in this case here). This has also the problem, that the notifications and so also the event-logs, are created on the compute-nodes (as far as I know) and so you would have to watch all compute-nodes by your tool.
Based on the fact, that I don't know, how much work it would be to write a tool to collect notifications over RPC and because I don't know, if all events you want to watch really creates a notification (base on the overview here: https://docs.openstack.org/ceilometer/pike/admin/telemetry-measurements.html), I would prefer number 1.
Its the easiest way to create a tool, which runs GET-Requests over REST-API in a regular interval and forward the results to the desired destination as your own custom notifications.
I followed the below references to get this working. Also, chatted with the author of this code and video.
https://github.com/gibizer/nova-notification-demo/blob/master/ws_forwarder.py
https://www.youtube.com/watch?v=WFq5JWXa9AM
In addition, I faced other issues:
By default, OpenStack server would not allow you to connect to RabbitMQ bus from remote host because of an IPTABLE rule. You will have to enable access to the RabbitMQ Port in the IP table.

Asterisk integration with custom ERP

One of our customers has an Asterisk phone center and want to integrate it with our ERP. The idea is that Asterisk calls an Oracle database procedure when a phone call is transferred to an extension. This Oracle procedure has 2 parameters, incoming phone number and destination extension.
Is it possible to do this with Asterisk API? Where can I find documentation or examples to do it?
I have read official Asterisk API documentation but don't understand how it works and where can I begin to search...
There are no documentation for "just integrate with ERP".
You can use ARI events or AMI events or CEL to make integrations. It will be highly depend of dialplan used
There are probably a dozen ways to do this using the various Asterisk subsystems, such as ARI and AMI, but one of the simplest might be to make a network call embedded in the dialplan.
There are several examples of how this might be done at https://www.voip-info.org/asterisk-call-notification/ ; for example, look at the description for YAC on that page, which shows how to make the call using netcat.
That method uses the System Application. Do be careful not to pass unfiltered text from e.g. the Caller ID information to the system, as someone might inject malicious code into the Caller ID.

HTTP POST from GOOGLE ASSISTANT to PRIVATE SERVER and convert response in voice

I want use Google Assistant from my phone to send HTTP POST command to my server. I have a simple webnms app running over it, this server support REST API and now I want to use Google Assistant to shoot GET or POST command to that server and return my output.
Is it something possible? I am not full time developer.
Yes, as #Prisoner says it is possible. It is not what you asked - but have you seen these ways that Google provides to get skills published without requiring a lot of developer savvy?
https://developers.google.com/actions/content-actions/
https://developers.google.com/actions/templates/first-app
I don't speak for them, but IMO Google's target audience for Action building apart from the above is those who have at least some familiarity with the JavaScript language and its "run-time" Node.
There is also this - which I haven't tried by the way.
https://www.techadvisor.co.uk/how-to/digital-home/easy-actions-google-assistant-3665372/
In case it is not obvious, Google Actions are essentially websites that interact with Google's assistant running on a Home device or a smart phone, say. Think of the Assistant as a browser initiating requests and your Action as serving them. If you can (build and?) deploy a server that handles POSTS over HTTPS on a publicly addressable URL, and if you can understand the JSON payload that the Assistant sends and respond with appropriate JSON to carry out you application then you are good to go.
Where you don't have a public IP address - e.g. in testing - you can use a tool like ngrok ( https://ngrok.com/ ) to reverse proxy requests emanating from the Assistant to your server.
I have slides for a presentation I did targeting fledgling developers who had never built an Action here
https://docs.google.com/presentation/d/1lGxmoMDZLFSievf5phoQVmlp85ofWZ2LDjNnH6wx7UY/edit?usp=sharing
and the code that goes with it here
https://github.com/unclewill/parrot
On the upside the code is about as simple as it gets. On the downside it does almost nothing. In particular, it doesn't try to understand language. As #Prisoner says you'll likely need a tool like Dialog Flow for that.
Yes, it is possible.
Your server will need to implement the Actions on Google API. This is a REST API which will accept JSON containing what the user is intending to do and specific information about what they have said. Your server will need to send back JSON indicating the reply, along with additional information about how to continue the conversation.
You will likely also want to use a tool such as Dialogflow to handle building the conversational script and converting a user's phrases into something that makes sense to you. You'll also need to use the Actions on Google console to manage your Action and provide additional details about how users contact your Action. All of this is explained in the Actions on Google documentation.
Simple Actions are fairly easy to develop, and can certainly be done by a developer as a hobby. Good Actions, however, take a lot more thought and planning. Google offers you to the tools - it is up to you to best take advantage of them.
I've found the solution.
In the "Action" console https://console.actions.google.com/project/sandbox-csuite/scenes/Start
Go to menu "Webhook", click "Change fulfillment method", and then select "HTTPS endpoint"

Appropriate http status code for confirmation

I'm implementing an API for a several different client programs to connect to, and I want the api to be able to send back an "are you sure you want to do this?" message, such as when trying to delete something via the api. Looking over the list of established http response codes, I don't see one that seems quite appropriate. I could always skip using a code and provide some other manner of communicating the confirmation, but I would really like to use a standardized method if possible.
The api is normally accessed via a client application, currently a JavaScript-powered one, but I've also made it so that it can be effectively used by directly accessing the api via web browser url.
In what regard would the "Yes I'm sure"-message differ from the "Delete entity 42" message? What would keep clients from immediately sending the "Yes I'm sure"-message? Does your API get accessed by machines or humans?
IMHO this should be solved in the user interface, not in the transport layer.

Resources