This Python script generates a Chuck Norris joke and personalizes it with a random name from a list. The joke is then sent to a Microsoft Teams channel via a webhook.
- Python 3.6+
- pymsteams
- requests
- Clone this repository or download the files
- Install the required dependencies:
pip install pymsteams requestsAlternatively, if you have a requirements.txt file:
pip install -r requirements.txt-
Get a Microsoft Teams Webhook URL:
- To create a MS Teams webhook, check the tutorial at https://medium.com/@jacopocastellano/chuck-norris-comes-to-ms-teams-a-joke-generator-script-a98e03146818
- Or follow the official documentation at https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=dotnet
-
Configure the script:
- Open
start_chuck.py - Replace
Insert_Here_Your_MS_Teams_Webhook_URLon line 25 with your actual Microsoft Teams webhook URL
- Open
Run the script with:
python start_chuck.pyThe script will:
- Fetch a random Chuck Norris joke from the API
- Replace "Chuck Norris" with a random name from the predefined list
- Send the personalized joke to your Microsoft Teams channel
- Names: You can modify the
list_of_nameson line 14 to add or remove names for personalization - Scheduling: Set up the script to run automatically using crontab (Linux/Mac) or Task Scheduler (Windows)
0 9 * * * /usr/bin/python3 /path/to/start_chuck.py- API Call: Fetches a random joke from https://api.chucknorris.io/jokes/random
- Name Selection: Chooses a random name from the predefined list
- Personalization: Creates a "Norrized" version by replacing the last name with "Norris"
- Text Replacement: Substitutes "Chuck Norris" in the joke with the personalized name
- Teams Integration: Sends the joke to Microsoft Teams via webhook
.
├── README.md # This documentation
├── start_chuck.py # Main script
├── requirements.txt # Python dependencies (optional)
└── .gitignore # Git ignore patterns
- Module not found errors: Make sure you've installed the requirements with
pip install pymsteams requests - Webhook errors: Verify your Teams webhook URL is correct and the channel is accessible
- API errors: The Chuck Norris API is free and doesn't require authentication, but check your internet connection
I am not responsible for the inappropriate use of the jokes generated by this script. Please use it at your own discretion and make sure to follow the guidelines and policies of your organization or platform.
- Chuck Norris API by Mathias Chilling: https://api.chucknorris.io/
- Original concept and implementation