I am trying to use Twit to send and recieve Twitter DMs.
When I create a stream like this:
var stream = T.stream('user');
I get a 404 error. I believe this is because the user stream has been deprecated.
What stream can I use instead to send and receive DMs?
That's correct, you will need to use the Account Activity API to receive Direct Messages in realtime. This is a webhook-based API. Twitter has a migration guide.
In summary:
Create an app with a listening URL for Twitter to post events to.
Register the webhook
Listen for incoming Direct Messages
Use the REST Direct Message API to respond.
There's also a full tutorial on this using a JavaScript package called autohook.
Related
I am trying to use the Twilio API and I would like to use the message content as a filter. So ideallay I would like to make a request like https://api.twilio.com/2010-04-01/Accounts/AccSID/Messages.json?body="test" and it would include all the messages that have the word "test" in their body whether inbound or outbound messages.
In Twilio docs I could only find filtering messages by date sent. Can the above use case be achieved with Twilio?
There isn't a parameter to filter message body content using the /Messages resource. You can look at the BulkExport API to export the messages to your datastore or capture the logs locally from your Application server upon origination and termination of the message responses and store those in your datastore for later filtering based on your DB logic.
BulkExport API Overview
Best Practices for SMS Message Logging
What the title describes can already be done easily via programs like Zapier, so I am hopeful that it can be done through Twilio functions directly.
Essentially, I have my CRM set up so that based on certain triggers, it sends a http POST request to the Twilio URL that controls SMS sending:
https://api.twilio.com/2010-04-01/Accounts/ + twilioAccSId + /Messages.json
For the most part, this works great!
I just want a way for Twilio to then respond by using a function to write a record into the CRM (using the CRM's APIs).
I would want the record written to include things like the delivery status of the message e.g. whether it failed, or was successful). I'm also open to exploring other ways where Twilio can transmit this outbound message info to the CRM through other means, and then having a function on the CRM then write a record!
Do you have the code to share of what you are attempting and the issue encountered? Or is the question more if this is possible? It is certainly possible.
You will use a statusCallback URL of your outbound POST to the messages resource, which will fire with the statusCallback messages and make an API call to your CRM to update the customer record accordingly. You can append a URL query parameter to your statusCallback, so you know which customer record to update.
Track Delivery Status of Messages
How to Share Information Between Your Applications
Passing Custom Information via Requests to Twilio
I need to find an Api/webhook, source code for youtube. Specifically, that Api/webhook will send me a notification only when a specific youtuber makes a direct live streaming transmission.
Thanks for your help.
You may refer with this link: Is there a way to get notifications from YouTube API when broadcaster is live. It stated that it requires a websocket connection with your API endpoint by using ws:// protocole at some point. Websocket listen to a server, and enable your browser to handle it's changes like events. So it's exacly what u need for notifications.
Also, you may use the GET https://www.googleapis.com/youtube/v3/liveBroadcasts endpoint which returns a list of YouTube broadcasts that match the API request parameters.
However, getting a notification will require some work. It will probably require polling the endpoint for changes to determine if a new broadcast has been started. I'm not aware of a PUSH API from YouTube to send a request to an endpoint of your choice to create a notification.
More info in the YouTube docs.
I would like to access the messages in the Twitter via the API in real time. A cursory search showed that it is possible to periodically send API-request to Twitter. In general, this is possible. 15 requests in 15 minutes is enough.
But I'm wondering, are there other ways to get information faster?
For example, is it possible to subscribe to notifications and receive a request from Twitter at a certain address?
Are you asking if Twitter has webhooks? The answer is yes
Review Securing Webhooks documention taking special note of the
Challenge Response Check (CRC) requirements.
Create a web app with an endpoint to use as your webhook to receive
events (e.g. https://example.com/webhook/twitter).
Make sure your webhook supports POST requests for incoming events and
GET requests for the CRC.
Register your webhook URL with your app using POST
account_activity/webhooks.
Use the returned webhook_id to add user subscriptions with POST
account_activity/webhooks/:webhook_id/subscriptions.
I am trying to figure out how to send a direct message to a bot in slack using the Slack API and get the response by the bot. For example, I use chat.postMessage:
curl -X POST -d
'token=xoxp-xxxx-xxxxxxxxx-xxxx&channel=BOT_ID&text=where?&as_user=true'
https://slack.com/api/chat.postMessage
The bot respond with:
I'm at hubot-server1.localI'm at hubot-server2.local
I want to capture the response. What Slack API I can use to capture? chat.postMessage doesn't return it.
Thanks for any reply.
Regards...
There are no API methods that will directly return a response from a bot. To capture responses of bots (and users) you need to read the messages from a channel.
With the Web API you can do that by calling channels.history for public channels (or groups.history private channels and similar names methods for other conversation types. you can also use the new conversations.history method to access all types of channels).
Those methods will give you all messages of a channel and you will need to filter out the right message within your app.
You can also get all new messages for a channel with the RTM API and the Events API.