• Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Craig Sweaton

Joke Twitter Bot

by

Twitter bot that will periodically tweet out a joke obtained from a joke API.

  1. Joke Twitter Bot

Joke Twitter Bot

Description

This is a Twitter bot that will periodically tweet out a joke obtained from a joke API https://icanhazdadjoke.com/

Installation

Run npm i to install dependencies

Setup

An environment file is required to contain the secret keys for the Twitter API and the joke API's URL. The naming convention for this file is [STAGE].env.json, for example dev.env.json.

This is the env file that should be placed in the project root.

{
    "JOKES_API_URL":"https://icanhazdadjoke.com/",
    "TWITTER_CONSUMER_KEY": "YOUR KEY GOES HERE",
    "TWITTER_CONSUMER_SECRET": "YOUR KEY GOES HERE",
    "TWITTER_ACCESS_TOKEN_KEY": "YOUR KEY GOES HERE",
    "TWITTER_ACCESS_TOKEN_SECRET": "YOUR KEY GOES HERE"
}

Testing

The bot can be invoked manually during development with the following command

sls invoke local -f bot

Deployment

  • Both the STAGE and REGION options can be used with this bot. If left out the bot will default to dev stage and eu-west-1 region.

Deploy command

sls deploy --stage dev --region eu-west-1

Notes

The API request in helpers/jokes.js sets a custom User-Agent header to identify users to the joke API owners. Please customise this to your library name.

Contents

  • Joke Twitter Bot
  • Description
  • Installation
  • Setup
  • Testing
  • Deployment
  • Notes

Related

GuidesPluginsExamplesSlack CommunitySupport