Twilio with c# asp.net webapi - c#

I am implementing simple Twilio service for sending sms using c#.
I want to receive the status of the message sent to any number, so I created Asp.Net WebAPI HTTP post method (status call back) and exposed to Twilio like below. But every time I send message, this http post method is not receiving any and my Twilio trial account logging the below message
You are receiving this email because your Twilio account has
encountered an error or warning and the On 1st error every day Alert
Trigger has fired. The most recent alert was:
"11200 - HTTP retrieval failure"
The URL I used for the status call back is public domain and https.
Am I doing something wrong here ? Please help me.
Code
var message = twilio.SendMessage(
"+14439173365",
"+1xxxxxxxx",
"Sample Twilio message",
"https://www2.xxxx.com/webservices/Reminder/V1/WebAPI/Reminder/TwilioAPI/MessageStatusCallBack");

Megan from Twilio here.
Can you check the full list of possible causes and solutions for your error here?
You can also see a non-trivial example of using the StatusCallback in this tutorial found here using C#:
https://www.twilio.com/docs/tutorials/walkthrough/eta-notifications/csharp/mvc#4
It can sometimes help to get these examples working and then make changes according to your application.
Hope this helps.

Related

Where should I configure webhook url to get the latest user send message from bot added telegram group

I have read some documents to understand the webhook configuration for getting the latest user send messages from bot added telegram group the documents and the links are this , this, this , telegram api doc and telegram bot doc
I understand the concept but I'm getting the confusion on configuration of webhook url to get the latest messages and where should I configure this webhook url.
Note :- Should configure this webhook url in our server(www.example.com)?
Example webhook url is :
https://api.telegram.org/bot{my_bot_token}/setWebhook?url={url_to_send_updates_to}
Suggest me how to work with telegram webhook. And get the latest user send messages.
You need to set Webhook on your own static web address, for instance:
https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/setWebhook?url=https://www.example.com
There should be POST-handler on this route, that way Telegram's updates can be received.
You must set your webhook manually.
You've got a bot_token and you know which url will receive the POST updates webhook_url
You run this link in your browser with your configuration:
https://api.telegram.org/bot{bot_token}/setWebhook?url={webhook_url}
After that any update will be send to your webhook url as a JSON
If you got an error 429: Too Many Requests, you must handle this in your code.
It comes because you are sending to many requests to the Bot API, and every bot has a limit 30 request/second.
So try to minimize requests as much as possible in your code and do some Thead.Wait() if needed

Microsoft Azure Graph API Subscription Errors on Validation request using Custom Api as Listener for notifications

I have looked at the post of people saying the resolved this issue by allowing the API to accept "text/plain".
Even though I have done so, I am still getting the below error:
"{ \"error\": { \"code\": \"InvalidRequest\", \"message\": \"Subscription validation request failed. Notification endpoint must
respond with 200 OK to validation request.\", \"innerError\": {
\"request-id\": \"ec325726-5b30-4cb1-bec5-3ba3debf88b0\",
\"date\": \"2020-03-23T13:02:01\" } }}"
I have tested my API on Postman using the same request Microsoft sends when they are validating an API.
All seems to be fine in Postman.
The image shows Postman results:
Please help.
Subscribing to user's mailbox settings for change notifications is not supported at the moment by Microsoft Graph. If you'd like to request support for such feature, please go to uservoice and create/upvote an idea.
If it were to be added to supported resources for change notifications, it more than likely that the resource would be /users/{userid}/mailboxsettings as /users/mailboxsettings is not a valid resource on Microsoft Graph. (resources for subscriptions follow the same pattern as the URLs of the APIs)

Receiving SMS in C# with RingCentral

I am able to send SMS using C#. But my problem is I don't know to receive those SMS.
I looked into following documentation with WebHook and C# here:
https://developers.ringcentral.com/guide/notifications/quick-start/webhook/c-sharp
But not sure how to do it exactly.
Can I get any help to know how I can receive the SMS. Any sample will be great.
There are 3 ways to receive SMS:
PubNub Subscription
WebHook Subscription
API Request
Here are some details:
Using PubNub, you can receive SMS.
Check it out here: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/SubscripotionTest.cs#L31
Since this is used by PubNub, so you don't need ngrok
If you want WebHook, you need to subscribe for push notification check the reference demo: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/WebHookTest.cs
The direct API of RingCentral APIs to receive SMS content in your C#, by calling this API inside your SDK is: /restapi/v1.0/account/~/extension/~/message-store/{messageId}/content/{attachmentId}. Here you need to put the message id and the attachment id to retrieve message content from message-store
Hope this help.

c# web api as jira webhook url

I have been tasked to implement a JIRA SMS notification(using Twilio) similar to its in-built email notification. I know this can be easily done using Zapier and Twilio.
But i am told to look for a workaround with out using Zapier.
The only option i think of now is to create a WebApi project that calls Twilio to send the SMS, host the WebApi project on a server and pass this URL as a WEBHOOK in JIRA.
For this i have created a C# class library which calls Twilio.
class
and after that i have added a new WebApi project for this solution and added the above class project reference.
and i have added a new controller:
controller
i am just calling the send method from the constructor with out any parameters which i think will do the job just from hardcoded number to a given number(in the controller.
but what i need is to pass in messageBody and recipientPhoneNumber from the JIRA webhook to this controller. Not sure how to do this.
As i am very new to WebApi's could some one please help me with the code. much appreciated.
Twilio Dev Evangelist here...
Mind dropping me a note at corey#twilio.com? I agree with the previous responses - this site may not be the best forum to support what you're looking for here, but I would be more than happy to directly help you out here.
but what i need is to pass in messageBody and recipientPhoneNumber from the JIRA >webhook to this controller. Not sure how to do this.
The way webhooks work is a little bit different than your assumption above. You cannot pass anything to JIRA webhook. JIRA POSTs data to the webhook (your API URL). Once you receive the data in your API controller action, you can construct a message body and recipient phone number (from e.g. user object passed in by JIRA; if that object doesn't have any phone number attribute, you might have to use a custom field).
As i am very new to WebApi's could some one please help me with the code. much appreciated.
No problem. I guess you have done the Twilio part alright already. Please visit MS docs to know more about Web API. You have to add a controller method so that it can be called by JIRA. So your final URL becomes this. You can then put this URL in JIRA as webhook. Replace hostname mycompany.com by your server hostname and change other url segments based on your situation.

Twilio SMS sandbox using C#

How do you use the Twilio sandbox mode with C#? I have a ashx.cs file that I am using to write my code. Would I put it there? If so, what does that look like?
There is no real great examples on their website on how to do this except for CURL and Ruby.
We are using TwiML to general an XML file tha t parses our data to send back and forth to the Twilio service. We don't want to be charged every time we send a test text message.
How would we set the Sandbox up so we could do some testing.
I found the Test auth Token and account Sid, but how do I use those?
We don't have them in our current application and we are specifying our .ashx page in Twilio to process our code.
Thanks in advance.
Twilio evangelist here.
So if you just want to test that your ASHX handler is generating the right results the easiest way to do this is to just fake a POST or a GET request to that handler. This lets you simulate the GET or POST request that Twilio will make to your app when it gets a text message.
You can see the parameters that Twilio will pass to your app when it receives a text message here:
http://www.twilio.com/docs/api/twiml/sms/twilio_request#synchronous
There are a whole bunch of ways to simulate these requests. cURL is one of them. If your ASHX is expecting query string values, you can also just load the ASHX directly in the browser and append those values in the URL. If the handler is expecting a POST request, I used a chrome plugin called Simple REST Client to make these.
Of course you can also Fiddler to make just about any HTTP request.
The Test Credentials really are more for simulating the use of the REST API (programatically sending SMS messages). I just wrote a blog post that shows how to use the test credentials to create integration tests:
http://www.twilio.com/blog/2013/05/automating-twilio-integration-tests-with-test-credentials.html
Hope that helps.
Devin

Categories

Resources