How can I trigger an API request using SMS? - request

Lets say I have 2 mobile phone numbers: X for Agent, Y for Merchant.
I want to be able to have a system where an SMS is sent from X to Y, and this triggers an API request in the Merchant's server, for example a POST request with data that looks something like this:
{
"mobile_number": X,
"type": "agent",
"amount": "240.00"
}
Hopefully you get the idea. How can I do this? Are there any readily available SaaS services that offer these things? Thanks.

If Y is going to be the receiving number that triggers the API request you could:
Get an account at https://portal.ytel.com/user/signup where you can
obtain a programmable SMS enabled number.
Buy an SMS enabled number in the portal or the API. Under number management put in a Webhook url under SMS Settings->SMS Request Url and this Webhook will post to the url any inbound SMS sent to it.
Parse the Posted Parameters to the URL for whatever you need from
it.
Execute a cURL request to your API endpoint and send over:
{"mobile_number": X,"type": "agent","amount": "240.00" }
Or whatever else you want, I'm assuming it will be different depending on what's sent in the SMS

Related

Discord Interprocess Communication - Read Messages

I'd like to abide by TOS but i am having tough time. I'm in paid server where I can't place a bot account. I simply want to consume the message content in my application (currently in python). What can I do? Can I write a hook to consume the messages from the GUI or from the web client? It seems what I want to do is not supported. Any thoughts?
Others have stated that you can apparently use use ipc and messages.read scope or RPC to receive messages but I don't know what resources are available to hook into and get the message content as it comes from the server.
There are multiple ways to read the messages from the client. You could use the Discord API with your account's token, but this is not allowed by the Discord ToS and thus is bannable (self botting). The other way is to use Discord IPC.
Discord IPC allows you to communicate with the Discord client by using named pipes. The default name is discord-ipc-0. You need a Discord application to use it.
The IPC protocol uses the same protocol as RPC, which is documented on Discord Developer Portal. You can also find more information on the IPC protocol on the discord-rpc official repo.
To put it simply, the packets you send through the pipe are serialized that way:
uint32 opcode
uint32 length
byte[length] jsonData
The data is a JSON encoded object, with a unique nonce parameter that is sent back on the answer, a cmd parameter for the command you want to use and optionally args and evt.
You would probably be interested in the AUTHORIZE, AUTHENTICATE, GET_CHANNEL and SUBSCRIBE commands. So I'll explain those four commands here.
But first, you need to connect to the IPC and do the handshake. This is done by sending a message with the opcode 0, your client_id and the protocol version. Here's what the JSON object should look like:
{
"v": 1,
"client_id": 332269999912132097
}
Once you're connected, you should receive a DISPATCH response with the user info. Every message you will send from this point should use the opcode 1
Now, you need to send an AUTHORIZE command This command allows you to ask an OAuth2 code from the client with the specified scopes, which will allow you to use the AUTHENTICATE command. Here, you would want the rpc and messages.read scopes. It should look like this:
{
"nonce": "be9a6de3-31d0-4767-a8e9-4818c5690015",
"cmd": "AUTHORIZE",
"args": {
"client_id": 332269999912132097,
"scopes": "rpc messages.read"
}
}
Please note that you need a redirect uri on your application for this to work.
The client should get a prompt. If he accepts, then your application would receive an oauth2 code that you can use to authenticate. The OAuth2 process is explained on the Discord Developer Portal.
After making your request to /oauth2/token with the code, your client id, client secret and redirect uri, you should be getting an access token that you can to authenticate, using the AUTHENTICATE command. Here is what it should look like:
{
"nonce": "5dc0c062-98c6-47a0-8922-bbb52e9d6afa",
"cmd": "AUTHENTICATE",
"args": {
"access_token": "CZhtkLDpNYXgPH9Ml6shqh2OwykChw"
}
}
If the authentication is successful, you should receive a response with evt set to null, application info and user info.
From this point, you are authenticated and you can read messages by using the GET_CHANNEL command to get the last messages, and by subscribing to the MESSAGE_CREATE event to get the new messages when they're sent. Those are documented on the Developer Portal.

How to create custom URL in apex to get Json response from third party application

I am sending some perameters to the third party application using rest api In one of the perameter I am sending A URL, This URL will use by third party application to send a json response after 5 or 10 min. My question is how may i create that URL for third party app that they will use to send the response.
If the 3rd party can send HTTP headers too you could send to them the current user's session id. If that user is API enabled (checkbox in profile/permission set) - you could write an Apex REST service that accepts POSTs. They'd call it with Authorization: Bearer <session id here> and it could work very nice. This trailhead might be a good start for you. (or can you contact their developers and maybe agree to make a dedicated user in SF for them so they'd log in under their own credentials and send it back?)
If they cannot send any special headers (it'd have to be unauthenticated connection to SF) - maybe you could make a Visualforce page, expose it as Site and then page's controller can do whatever you need. Maybe you already have something public facing (community?), maybe it'd be totally new... Check https://developer.salesforce.com/docs/atlas.en-us.206.0.salesforce_platform_portal_implementation_guide.meta/salesforce_platform_portal_implementation_guide/sites_overview.htm
If none of these work for you - does the url have to ping back to Salesforce. Maybe you have control over another server that can accept unauthenticated requests like that and have that one then call SF. Bit like a proxy. You could even set something up fairly easily on Heroku.
Last but not least. This would be extremely stupid but if all else fails - in a sandbox enable Web-to-Case or Web-to-Lead and experiment with these. At the end of the day they give you an url you can POST to and pass a form with data. I think it'd have to be Content-Type: application/x-www-form-urlencoded and if you mentioned JSON they're likely to send it as application/json so might not work. If it works - you could maybe save the payload in Description field of Cases (special record type maybe?) and do something with it. I'm seriously not a fan of this.

Receive slack bot messages via requests to external URL

Is it possible to receive direct messages on behalf of a slack bot via POST requests to a certain domain?
I want to have an endpoint in Google App Engine that receives incoming direct messages from Slack via POST requests, and posts messages back via the API. Is it possible?
You can use the new Events API. Create a bot, subscribe to message.im events, and set your endpoint as the callback URL
You just need to set up an "outgoing webhook"in slack and point it to whatever endpoint you need on your GAE server. In order to respond just use an "incoming webhook" to receive the answer.

AngularJs: Respnd to Http post from third part server

I am developing an app using AngularJS and NodeJS. Being new to both I am struggling a bit.
My app is communicating with payment gateway to facilitate payments. Flow goes like MyApp-->Payment Gateway --> MyApp. I am able to send the request to payment gateway. Problem is I am not able to figure out how I will handle response that is coming from payment gateway. Payment Gateway is sending some data in the post request. I need to process this data before showing results of transaction to user.
Technically speaking I know what needs to be done. Like Step 1) Giving a return URL to Payment Gateway to which Post request will be sent. Step2) This HTML URL of my application will send data received from payment gateway to server side for processing. Step3) Based on processed results I will show transaction result to user.
Where I am struggling is show to achieve this using AngularJS and Nodejs. Pls help
You can use Angular's $http service to easily send and get data from server.

About google app gmail api

I was trying to send emails to my client from my application after few sent mails all mails bounces back with a message saying "You have reached a limit for sending mail. Your message was not sent." And one more thing when i see my developer console gmail api it still showing 0% usage.what is this issue? is this a bug or something else?
There's an extra limit on sending because it's a vector for abuse--it doesn't show up in the developers console but it's the same as sending via SMTP or the web interface.
This seems to have a good overview:
http://www.labnol.org/internet/email/gmail-daily-limit-sending-bulk-email/2191/

Resources