How to automate message service - python

I have a message service , where i can set time frame to send message lets say between 9 AM to 10 AM , now i can send message using some Rest api services ( internal api ) , but once i send it will be in enqueue , basically i don't know when it will be sent , now i want to automate this validation part ( once i sent message my script should check status each time lets say every 5 min , if sent status success it should end test case if still status not update it should retry to check upto 5 times )
Can any one help me on this .. Thanks in Advance.

Related

Telegram recurring message to one user

I need to send two specific recurring messages to a user in telegram .
The first message is followed by the second after some seconds .
It will be the same two messages every 10 mn ,everyday !
Example :
RecurringMessage1 :
I AM READY
then after some seconds comes the second one :
RecurringMessage2 :
YOU CAN SEND NOW
This would be repeated every 10 mn every day and so on .
The receiver is a bot on telegram that has a #username only .
( i dont have the skills to get his chat id , and restricted to include him in any group ) .
Any help is highly appreciated .
Tried using scheduled messages feature of telegram , it works but it is completely unpractical to use it due to the large number of recurring messages .
Thank you
You can try to use telethon module to get the chat id of the bot while it's reading all your current incoming messages.
from telethon import TelegramClient, events
Otherwise if you remove the '#' from the bot's name e.g. #MyBot, you should be able to use https://t.me/MyBot as an alternative.

How to get instant response (one of many) from API

I need to make such an architecture:
The first block is some application that sends five POST requests to the global API - which is second block. This API gets all five requests, which have data and number from 1 to 5. This number tells the API where to send the data in local network. Third block is my local network that has 5 APIs which receive data and after some computings send back json.
Here comes my problem. How to send back these response (lets say 200 code with specific json) to first block, through the second, immidietly? I don't want second block to wait for all 5 responses and then send them to first in one chunk. How to make it instant - for example 4th local API computes something, sends back json data to second block (global API) which sends it to first app?

How to send multiple delayed responses from Python Webhook once an intent is been triggered?

I want to send multiple, delayed responses from the webhook written in python, once an intent is been triggered by the user. First response I want immediately after triggering the intent and another response I want after some processing to be performed on top of the user utterance.
For example:
User : I want my account balance.
BOT : Please tell your account number for details.
User : my account number is 218497234.
BOT : Hold-on a bit we are fetching your details.
BOT : Welcome John, your account balance is $70000.
In the above example, this is a bank-bot, which replies to user queries. Currently fetching-up account balance for a user supplying account number. The last two responses from the BOT are from the webhook when say "account_balance_check" intent is been triggered. First response is immediate, asking the user to be patient and wait for the account details , while the second response is after fetching the account details from a db using account number.
Another way could be to trigger response from the bot, without utterance from the user. In the above case, is there anyway, bot itself can send response to user after telling him to wait? Please note that after telling user to wait, we don't want user utterance to trigger second response.
Unfortunately, you cannot do that in Dialogflow because once you send the response then your agent will not be able to send the response without any user input or event call.
Here is an answer if your process does not take a long time. Once you get the user request, send them the waiting message with the "OK" suggestion. Once the user clicks on the suggestion, you can show the response. Also, process the request with some API and save your data in a common file that you can access through both API and agent and then show the response to the user from the file.

How to check for incoming new messages using Gmail API

I have set up a python script that can pull data from Gmail account, but I would like to set it up in a way that it would only pull new message since the last time I made the API call (I will be pinging the server regularly).
I have looked at Push notification and Pub/Sub, but I am not quite sure if these are relevant or I should be looking at something else. Gmail also has Users.history: list function, but I am wondering if this can be used in any useful way.
You could list messages as you usually do, but saying that you want messages after a certain timestamp. This way, you can poll for new messages e.g. every minute, giving the last time you checked for messages in seconds since the epoch:
Request
q = is:unread AND after:<time_since_epoch_in_seconds>
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=is%3Aunread+AND+after%3A1446461721&access_token={YOUR_API_KEY}
Response
{
"messages": [
{
"id": "150c7d689ef7cdf7",
"threadId": "150c7d689ef7cdf7"
}
],
"resultSizeEstimate": 1
}
Then you just save the timestamp when you issued the request, and use this timestamp one minute later.

Is there any way to sending user defined unique key in request to SMSC and getting it back in delivery report message?

Currently I am working on SMS GW. I would like to know the following things :
When you pass extra optional parameters through SUBMIT_SM, is there any setting needs to be done at SMPP side.
How to get extra optional parameters)being sent in request from client) in the delivery message string(mesage id, done date, dlvrd, err code etc)
How to pass a unique key while submtiting message so that when the delivery report message comes, you can fetch that key and one/more parameters from the delivery message string and update it in database?
What is difference between SUBMIT_SM, DATA_SM and DELIVER_SM?
Is there any way where i can customize the text in delivery message .Normally part of outgoing message is displayed. Can i get full message or specific part of message from SMSC?
Thanks,
Varun

Categories

Resources