GithubHelp home page GithubHelp logo

fbsamples / workplace-platform-samples Goto Github PK

View Code? Open in Web Editor NEW
182.0 47.0 170.0 114.35 MB

Sample code to enable Workplace customers to make the most of the features of the Workplace Custom Integrations platform.

License: Other

JavaScript 23.92% Python 26.56% CSS 2.89% PowerShell 36.26% EJS 1.71% PHP 5.76% Procfile 0.02% HTML 2.88%

workplace-platform-samples's Introduction

workplace-platform-samples's People

Contributors

aherreradev avatar alecvl-xmd avatar antiklesys avatar aothepro avatar b-bell avatar changtom avatar claudia-m-kaiser avatar colmdoyle avatar connortreacy avatar csesena avatar dependabot[bot] avatar dvahia avatar eduardogomes avatar frsechet avatar georgzoeller avatar givemelove avatar newalexandria avatar ohtangza avatar panreel avatar rohitgoyal18 avatar shintaliem avatar tbass134 avatar tk48 avatar tryrobbo avatar velik0ff avatar yoongyj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

workplace-platform-samples's Issues

Not able to update account records using python scripts provided

Hello ,

I have recently landed on your page as we are investigating a proper way to update workplace account information for our org.

We started experimenting with the the scripts you have provided here.

With below CSV file , we are getting error as Bad request ..

cat upload.csv

Email,First Name,Last Name,Job Title,Department,Phone Number,Location,Locale,Manager Email
[email protected],user101,user101,Title,Department,,Location,en_US,

Error

python scim_agent.py -c upload.csv $ACCESS_TOKEN
validating...
---> Valid File <---
Creating users...
Creating user [email protected]
400:Bad Request
Updating managers...
==========START ERRORS==========
Failed to create user with email [email protected]
==========END ERRORS==========

Can you suggest if we are doing anything wrong ? ( We are providing actual accesstoken in the command line )

Any help is appreciable

Account Management Example

Hi!

I need update the users information in workplace,
I'm using the account management example, but when i update the user's information,
the department section is not updated.

Can you help me?

Shockingly bad examples

I am appalled that a company of this size, with a commercial product you are trying to sell to companies, publish SHOCKINGLY bad examples. Seriously, is there not a single competent person anywhere in this organization?

Take the AccountManagement examples. Atrocious.

1/ They don't compile in any version of Python newer than 2.7, that's bad but not terrible
2/ OK, so they rely on request - now, that won't install on Windows using pip, and it is also entirely unnecessary, for goodness sake, we are talking about such simple stuff as http get here.
3/ They rely on a module csv_header, this is (at least for those of us who haven't spent a decade around python) nowhere to be found

Have you people never heard about complete, and runnable examples? Seriously! This is so bad!

Publish a bot

Can I publish a workplace's bot so that other company can use it as well?

Error during export

Hi all,

I downloaded and ran the export function
python scim_agent.py -e Export20171012.csv <access_token> <scim_url>

But I am getting the error shown below:
Exporting users to: Export20171012.csv
Traceback (most recent call last):
File "scim_agent.py", line 250, in
func_arg[sys.argv[1]](sys.argv[2], sys.argv[3], sys.argv[4])
File "scim_agent.py", line 130, in exportUsers
userCollection = scim_sdk.getUsers(scim_url, access_token, 1, userCollection)
File "D:\G_DRIVE\WPFB\PYTHON\SAN\ORIGINAL_WPFB_FILES\scim_sdk.py", line 151, in getUsers
totalResults = result_json[FIELD_TOTAL_RESULTS]
KeyError: 'totalResults'

Any idea what may have caused this?

Export User Data Script: Type Error

I tried running this script: SupportScripts/Python/ExportUserDataWithInsights/export_user_data.py

But I'm getting type errors on lines 25, 63 and 65. As recommended by the readme file the only change I made was to include my access token.

Script throws an error when updating only one record or the last record

The script is throwing the following errors when it is being run to update just a few records (e.g. the excel file has only one NewEmail populated or two).
When the excel file contains only one NewEmail record to update it throws the following error message:

ConvertFrom-Json : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\changeBulkEmail.ps1:111 char:47
+ ...            $msg = ($_.ErrorDetails.Message | ConvertFrom-Json).Errors ...
+                                                  ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [ConvertFrom-Json], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Cannot index into a null array.
At C:\changeBulkEmail.ps1:111 char:13
+             $msg = ($_.ErrorDetails.Message | ConvertFrom-Json).Error ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

When there are two NewEmail records to update instead it correctly processes the update of the first one and then throws the same error as before when it tries to update the second one.

It seems the line creating the issue is:

The line creating the issue is:

$msg = ($_.ErrorDetails.Message | ConvertFrom-Json).Errors[0].description

Changing it to:

$msg = ($_.ErrorDetails.Message).Errors.description

resolves these errors.

Unable to Create a Group Post

I have every single permission enabled on my Workplace bot, but I am unable to create a Group Post. This was working fine yesterday.

Request:

curl 'https://graph.facebook.com/{{group_id}}/feed' --header 'Content-Type: application/json' --header 'Authorization: Bearer ACCESS_TOKEN' --data '{
	"message": "hello"
}'

Response

{
    "error": {
        "code": 1,
        "message": "An unknown error occurred"
    }
}

Group Feed Download Not Paging Properly

The group feed only returns 25 records max I believe. Even if I set the DEFAULT_LIMIT to 25, it's still not pulling all the data and doesn't appear to be paging properly. I have tried to debug it myself but cannot seem to figure it out. Any help would be greatly appreciated.

Cheers!
Jon

Code errors

I came across a couple of errors in the code and accompanying notes for this sample:

  1. Contrary to the accompanying notes, the code uses the cron module rather than node-cron which has no CronJob object. Perhaps the notes could mention that this module needs to be installed separately, or include a dependency to it in package.json .
  2. On line 44 of clock.js the url makes no sense. Either the notes should say that .env should be modified such that TARGET_GROUP=/<group_id>/ or line 44 should be changed to include the slashes: url: '/' + TARGET_GROUP +'feed.

Nick Oates

Group creation not working

In the manage groups example, the group creation is not working.

It always returns "Invalid group id".

I wrote a script that does the same in NodeJs (https://jsfiddle.net/cold/9L4owe6p/1/) and got the same error:

{  
   "error":{  
      "message":"Invalid group id",
      "type":"OAuthException",
      "code":117,
      "error_subcode":1855195,
      "is_transient":false,
      "error_user_title":"Cannot Create Group",
      "error_user_msg":"Groups can only be created inside communities.",
      "fbtrace_id":"A7GV6QAtXEa"
   }
}

Is there a new parameter to provide? I tried with group_id, groupId,group, etc... but could not find one that work.

[DownloadGroupFeed]Japanese Character can't be recognised

I downloaded and ran download.py in "DownloadGroupFeed" project.
But I found the Japanese character named group can't be recognised.

The following message is displayed.

--
Traceback (most recent call last):
File "download2.py", line 129, in
row = [item["id"], item["permalink_url"], item["created_time"], item["updated_time"], item["from"]["name"], item["from"]["id"], item["message"].decode("utf-8").strip(), item["link"], item["likes"]["summary"]["total_count"], item["comments"]["summary"]["total_count"]]
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-13: ordinal not in range(128)

How should I fix this?

I confirmed that the English named group can be downloaded.
I ran this on Japanese Windows10 OS.

FYI, I found two another Japanese environment issues.
1.

Traceback (most recent call last):
File "download2.py", line 111, in
for group in getGroups():
File "download2.py", line 77, in getGroups
params = "?fields=feed.since(" + SINCE.strftime("%s") + ").limit(1),name,updated_time&"
ValueError: Invalid format string

I changed
SINCE.strftime("%s")
to
SINCE.strftime("%S")

s->"S"

This happens on line 42 too.

--
Traceback (most recent call last):
File "download2.py", line 121, in
with open(csv_filename, "wb") as csvfile:
IOError: [Errno 22] invalid mode ('wb') or filename: u'2017-11-23 17:02:03 2094457190639666 FW Test Forum.csv'

I changed
csv_filename = SINCE.strftime("%Y-%m-%d %H:%M:%S")
to
csv_filename = SINCE.strftime("%Y-%m-%d %H_%M_%S")
on line 115.

":" can't be used in the file name on Windows OS.

Export Users failed using AccountManagement script

Hi,
We're trying to use Python Scim_Agent available here : https://github.com/fbsamples/workplace-platform-samples/tree/master/AccountManagement Python 2.7 is installed, Requests module is also installed.

After the installation, we test the call to export all members : python scim_agent.py -e export.csv [access_token] https://www.facebook.com/scim/v1/Users but it failed :

Exporting users to: export.csv Traceback (most recent call last): File "scim_agent.py", line 244, in func_arg[sys.argv[1]](sys.argv[2], sys.argv[3], sys.argv[4]) File "scim_agent.py", line 124, in exportUsers userCollection = scim_sdk.getUsers(scim_url, access_token, 1, userCollection) File "/home10/postgres/workplace_by_facebook/accountmanagment/scim_sdk.py", line 145, in getUsers totalResults = result_json[FIELD_TOTAL_RESULTS] KeyError: 'totalResults'

We supposed that the access token is maybe wrong. We create another custom integration to use a new access token

Thanks by advance for your help.
Fabrice.

Can't update startdate field

Using the provided scripts, I can export user data no problem. Importing/updating data, I can't update the start date field.

I download the data just fine with "Python.exe scim_agent.py -e download.csv"; my process reads that data, updates it from my HR system by updating supervisor and start date fields, and writes the data to a new CSV file Updates.csv. I then attempt to update workplace by processing the updated .csv file:

Python.exe scim_agent.py -u updates.csv
validating...
---> Valid File <---
Updating users...
Updating user [email protected]
400:Bad Request
...

Updating user [email protected]
400:Bad Request
Updating managers...
Updating user [email protected]
200:OK
Updating user user [email protected]
200:OK
...
Updating user [email protected]
200:OK

The first pass fails, which is only updating the start date, as all other data is exactly as exported from Workplace. The second pass succeeds, which is just updating the supervisor's ID.

Note that while the exported data for start date is in Unix date format, the validation phase of the script bombs out if the date is not passed back in in YYYY-MM-DD format; Workplace central support acknowledges that this is the correct way to pass it back in, and that is what I'm doing.

Any advice on getting the script to successfully update the start date?

Thanks, all!

The /attachments edge not returning attachments

Hi, I have a strange issue.

I have 2 workplace posts in the same group, one next to another and they both contain some images.
The API returns images as attachments for one post, but not for the other one.

What could be the reason for that?

Thanks

FeedPoster example error

/root/workplace-platform-samples/FeedPoster/node_modules/cron/lib/cron.js:295
source = this.source.replace(/[a-z]{1,3}/ig, function(alias) {
^

TypeError: Cannot read property 'replace' of undefined
at Object._parse (/root/workplace-platform-samples/FeedPoster/node_modules/cron/lib/cron.js:295:23)
at Object.CronTime (/root/workplace-platform-samples/FeedPoster/node_modules/cron/lib/cron.js:37:8)
at new CronJob (/root/workplace-platform-samples/FeedPoster/node_modules/cron/lib/cron.js:395:18)
at Object. (/root/workplace-platform-samples/FeedPoster/clock.js:65:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)

Please help me out, I am a beginner in node

Invalid Webhook Subscription request

The Webhook subscription request returns the following:
{"error":{"message":"An unknown error occurred","type":"OAuthException","code":1,"error_subcode":1929002,"is_transient":false,"error_user_title":"Invalid Permissions","error_user_msg":"You could not subscribe to some of the fields requested due to a permissions error.","fbtrace_id":"HFfM9wXTRyC"}}

Is facebook workplace supports rich cards in chat bot messaging?

capture
we buit custom integration bot . we hooked up integration details like app id , app secret, token etc., to facebook messenger channel in bot framework using azure. we are able to send and receive messges in workplace chat for the chat bot we created. We also wrote the code for rich cards (Thumb nail card , adaptive card, hero card etc.,) to display in workplace chat. But rich card(s) is not getting displayed. Is facebook workplace supports rich cards to shown in chat bot messaging?Attached an image for reference of thumbnail image not showing in chat bot messaging.
Bot Code Developed in C# .NET

Examples -> Permissions doc

One thing that would be helpful for setting up is a list of the permissions that each example needs. Something like -

FileAnIssue requires Read group content and Manage group content

post 'see more' button erase text format

My text is split in two div which erase the format I've applied on it.
Half of the sentence is visible in bold while refreshing but when I click on the 'see more' button the rest of it appears without the bold format applied.
In source code, the bold is applied on the full text.
Yet when look on the CSS the text is randomly splitted in two div. Can you tell me how to fix that ? So that the full text will be included in the same div ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.