Hi All,
I want to ask into the forum about our concerns below:
Last night we was able to receive webhook DM (@PrimeTeknologi), App ID: 23608973, we use API v1.1, it worked very well last night, but this morning we tried it again but it didn’t receive webhook DM again!, really confuse about this, but now I suspect this is because we use Free version with sandbox environment, CMIIW.
We still in doubt, will it still happening if we upgraded to Premium? can we have something like one month free trial for Premium?
I knew there is no 100% delivery guarantee but I believe the Premium ones would be better, but I can’t prove my thoughts to my Boss.
Can we have an official letter from Twitter about no 100% delivery guarantee and any other terms and conditions?
and as our platform is multi-tenant meant multi customers, so our platform will receive and reply our customer’s DM on behalf of our customer, do our customers also need to purchase Account Activity API or just us?
Please help me out from this unpredictable webhook problem.
Thank you so much in advance
good day!
Question #1
The free tier is a trial version which is not much different from the paid version. The most noticeable difference is the subscription limit. In addition, there are several other features such as the ability to retries and replay. Both retries and replay features are indeed capable of repeating a constrained event.
But the loop will be accepted when the webhook doesn’t have a problem, as long as the webhook’s flow is still problematic then the loop will still not be accepted by the server.
Question #2
The error code is the key to troubleshooting, it seems to me if the server can receives events fine within a certain period, then suddenly stops and can’t receives events at all, or the webhook will work again when re-setup from the initial step, it seems this is related to the CRC code challenge.
A CRC will be sent when you register your webhook URL, so implementing your CRC response code is a fundamental first step. Once your webhook is established, Twitter will trigger a CRC roughly every 24 hours from the last time we received a successful response. Your app can also trigger a CRC when needed by making a PUT request with your webhook id. Triggering a CRC is useful as you develop your webhook application, after deploying new code and restarting your service.
Docs: https://developer.twitter.com/en/docs/twitter-api/premium/account-activity-api/guides/securing-webhooks
1 Like
@gauloics
The CRC was triggered successfully, I put a log file in there, and I was also able to trigger the CRC and it also arrives, the problem is DM message doesn’t arrive in the POST webhook, I put a log file in the 1st row of the POST method (See below), but it doesn’t arrive there!
please help me, thank you so much
C#
[HttpGet]
[Route("/Twitter/")]
[AllowAnonymous]
public async Task<ActionResult> Listen_Get()
{
try
{
var _qs = Request.QueryString;
if (Request.Query.ContainsKey("crc_token"))
{
string crcToken = (string)Request.Query["crc_token"];
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
byte[] keyByte = encoding.GetBytes(Models.Twitter.Consumer_API_Secret);
HMACSHA256 hmacsha256 = new HMACSHA256(keyByte);
byte[] messageBytes = encoding.GetBytes(crcToken);
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
string hashstring = Convert.ToString(hashmessage);
string response_token = Convert.ToBase64String(hashmessage);
string sha256responsetoken = "sha256=" + response_token;
string jsonData = "{\"response_token\":\"" + sha256responsetoken + "\"}";
Helper.SaveLog("TwitterController.Listen_Get : here2 " + jsonData, Helper.Log_Mode.Info);
return Content(jsonData, "application/json");
}
}
catch (Exception _ex) { Helper.SaveLog("TwitterController.Listen_Get: " + _ex.ToString(), Helper.Log_Mode.Error); }
finally { }
return NotFound();
}
[HttpPost]
[Route("/Twitter/")]
[AllowAnonymous]
public async Task<ActionResult> Listen_Post(object _o)
{
try
{
Helper.SaveLog("TwitterController.Listen_Post : here1 ", Helper.Log_Mode.Info);
}
catch (Exception _ex) { Helper.SaveLog("TwitterController.Listen_Post: " + _ex.ToString(), Helper.Log_Mode.Error); }
finally { }
return Ok();
}
it’s weird if the crc challenge is successful but the event doesn’t come or it ever comes but stops after some time.Any examples of when the webhook worked and when it didn’t?
If the reader of this post is a C# expert maybe you can help
1 Like
like yesterday night we could received DM webhook and able to reply to it, it was worked very smooth last night, but this morning, I wasn’t able to receive DM webhook any more!.. so weird! but this is happening right now!
What about the last log before the event stopped being received? Maybe there’s a clue there
Or try using a local server first to test whether the problem still occurs or not, for this you must at least turn on the device for 2x24hours
DM only at 22:43 last night, again I suspect this is about the free version, I want to purchase but I’m not sure
Have you ever tried this?
I mean is there an error in the last log history ?
How many subscriptions do you currently handle?
I’ve 2 subscriber, Using the free tier, and all works fine, I don’t think it’s a free tier problem
I suggest you try a local server, if the local server is running well, maybe you can ask your hosting service.
btw, do we need to regenerate Customer API Key, Secret, Access Token, etc when we want to register a new trial webhook or after we changed something like callback address etc?, I don’t think so, please CMIIW
No, You can use the old one, changing the callback url doesn’t affect your key
If my GET Webhook returns like the following, it means Twitter should be able to start sending to webhook using POST right?
{“response_token”:“sha256=3LvOU5pGEoxxV3c4Daz9Ba/aq3XTVz1IQgwTayT57z0=”}
is there anything else should I consider after getting the above response_token?
It’s like the code returned when handling a crc challenge, and it will be repeated at least once in 24hours.
If your hosting is on a cold start, like most free hosting services, it will go into sleep mode after a while of inactivity, then the CRC challenge may not pass when requested by the webhook at any time.
but like today, I have tried many times to trigger the CRC and the GET webhook triggered and returns response_token, but again the DM webhook doesn’t arrive
What about other activities such as like, follow, etc. ?
Is the subscribed account your second account or not?
We only play with DM.
Q: Is the subscribed account your second account or not?
A: what do you mean?
I have 2 accounts, my personal @WinanjayaA and it subscribed to @PrimeTeknologi
from @WinanjayaA send DM to @PrimeTeknologi … any problem with this?
and in @PrimeTeknologi, I also have turned off the Quality Filter option and turned off the mute notification options.
No, yes, I mean if the account that is subscribed is your own account, it means you can do various test events
Ah, You could try opening the filter to try different events, whether the DM only crashes or all events, this identifies if there is a problem while you are filtering DM events. This is very possible if the CRC challenge goes well but the DM is not getting.
Hi,
that’s what I did now, I just put a log on the 1st row of the POST
Twitter should send all messages with POST method to https://mydomain.com/twitter
it doesn’t appear there!
[HttpPost]
[Route("/Twitter/")]
[AllowAnonymous]
public async Task<ActionResult> Listen_Post(object _o)
{
try
{
Helper.SaveLog("TwitterController.Listen_Post : here1 ", Helper.Log_Mode.Info);
}
catch (Exception _ex) { Helper.SaveLog("TwitterController.Listen_Post: " + _ex.ToString(), Helper.Log_Mode.Error); }
finally { }
return Ok();
}