C# sending Facebook message to myself with FBClient_Simple library not received.

Gennady Gurin 251 Reputation points
2026-11-12T03:36:37.68+00:00

After running I check my Facebook account, under my profile, no message received,

even though program says: "FB Message sent with ID:..".

I attached 2 files, my code and FBClient_Simple.cs library.

CS_code_sample.txt

fbClient_Simple.cs.txt

Get back, thanks in advance.

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Harry Nguyen (WICLOUD CORPORATION) 690 Reputation points Microsoft External Staff Moderator
    2026-11-12T04:46:08.04+00:00

    Hi @Gennady Gurin ,

    Thank you for sharing your code and the FBClient_Simple implementation.

    I took a closer look at both files, and I noticed something that may help explain why your application displays a message ID even though no message appears in Messenger.

    The overall flow of your code makes sense: you attempt to log in, retrieve your user ID, send a message, and then display the result.

    However, the FBClient_Simple implementation you shared appears to be a sample designed to simulate these operations rather than communicate directly with Facebook Messenger.

    For example, in the DoLogin() method:

    await Task.Delay(100);
    generatedAccountId = Guid.NewGuid().ToString();
    loginState = true;
    

    Here, Task.Delay(100) simply pauses the program for 100 milliseconds. The method then generates a random ID and marks the login as successful.

    This is useful when testing an application's flow, but it does not actually authenticate your Facebook account.

    Similarly, in the SendMessage() method:

    await Task.Delay(100); 
    return $"msg_sent_{Guid.NewGuid().ToString().Substring(0, 8)}"; 
    

    The method generates a message ID locally without sending a request to Facebook.

    This would explain why your application reports a message ID even though no message is received.

    To send an actual Messenger message, the application would need an implementation that communicates with Facebook's messaging service.

    There is an existing third-party C# project called fbchat-sharp that provides a Messenger client implementation. However, it uses an unofficial Facebook interface, so compatibility with the current Messenger service cannot be guaranteed.

    For supported integrations, Meta also provides the official Messenger Platform API, although this follows a different model involving Facebook Pages rather than direct personal-account messaging.

    Before suggesting a specific implementation, could you please confirm whether the FBClient_Simple file you attached is the complete version used by your application, or whether you have another version that performs the actual Facebook requests?

    This will help determine the most appropriate next step.

    If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation

    Thank you.

    Was this answer helpful?

    1 person found this answer helpful.

  2. AI answer

    2026-11-12T03:38:56.4366667+00:00

    A returned message ID does not confirm that the message reached your personal Messenger inbox; for supported delivery, send through a Facebook Page to your personal account’s Page-scoped ID after that account has first messaged the Page.

    Supported test procedure

    1. From your personal Facebook account, open the Page in Messenger and send it a message.
      Messenger requires the recipient to initiate the conversation before the Page can reply.
    2. Obtain that personal account’s Page-scoped ID (PSID) from the Page’s conversation/webhook data.
    3. Send to the PSID—not the Page ID, profile ID, or session.user.uid—using:
      • POST /<PAGE_ID>/messages
      • A Page access token
      • The appropriate messaging_type
      • recipient.id set to the PSID
    4. Check the conversation in Messenger, not merely the Facebook profile page.

    A successful Send API response contains both recipient_id and message_id; the recipient must be a valid PSID associated with the Page conversation.^1^

    A minimal C# request has this shape:

    using var client = new HttpClient();
    
    var body = new {
        recipient = new { id = recipientPsid },
        messaging_type = "RESPONSE",
        message = new { text = "Test message" }
    };
    
    var response = await client.PostAsJsonAsync(
        $"https://graph.facebook.com/{pageId}/messages?access_token={pageToken}",
        body);
    
    string result = await response.Content.ReadAsStringAsync();
    Console.WriteLine($"{(int)response.StatusCode}: {result}");
    response.EnsureSuccessStatusCode();
    

    Keep the Page access token out of source control and logs.

    Why the current library result is inconclusive

    The FBClient_Simple sample belongs to the third-party fbchat-sharp project and creates a thread using session.user.uid before calling sendText. Its send implementation also creates local/offline message identifiers while processing Facebook’s response. Consequently, the text FB Message sent with ID: ... should not be treated as proof that Messenger accepted and delivered the message.

    The available repository history shows its latest listed commits were in June 2022, while reported receive-event failures also exist in its issue tracker.^2^ This does not prove the same failure here, but it means compatibility with Facebook’s current private endpoints cannot be assumed.

    Since the program already returns an ID, the next useful diagnostic is to log the complete HTTP status and response body produced by the send operation, with cookies and tokens redacted. Do not only test whether the returned string is non-null. In .NET, HTTP failures must be detected from IsSuccessStatusCode or EnsureSuccessStatusCode; HttpClient does not necessarily throw merely because the server returned an error response.^3^

    If FBClient_Simple does not expose the raw response, add temporary logging around the underlying PostAsync/SendAsync call:

    using HttpResponseMessage response = await client.SendAsync(request);
    string responseBody = await response.Content.ReadAsStringAsync();
    
    Console.WriteLine($"HTTP {(int)response.StatusCode}");
    Console.WriteLine(responseBody); // Redact tokens/cookies before sharing
    
    if (!response.IsSuccessStatusCode)
        throw new HttpRequestException(responseBody);
    

    If the response contains no server-issued recipient/thread confirmation, the displayed ID is insufficient evidence of acceptance. If the library depends on undocumented personal-account endpoints, there is no supported C# repair established here; replace that path with the Page-based Messenger Platform flow above.


    References

    1. Send a message - Messenger Platform - Meta for Developers
    2. #29 onMessage not working
    3. Make HTTP requests with the HttpClient class
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.